new semester, new repo structure
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*
|
||||
* This generated file contains a sample Java application project to get you started.
|
||||
* For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
|
||||
* User Manual available at https://docs.gradle.org/7.5/userguide/building_java_projects.html
|
||||
*/
|
||||
|
||||
plugins {
|
||||
// Apply the application plugin to add support for building a CLI application in Java.
|
||||
id 'application'
|
||||
}
|
||||
|
||||
repositories {
|
||||
// Use Maven Central for resolving dependencies.
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Use JUnit Jupiter for testing.
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2'
|
||||
|
||||
// This dependency is used by the application.
|
||||
implementation 'com.google.guava:guava:31.0.1-jre'
|
||||
}
|
||||
|
||||
application {
|
||||
// Define the main class for the application.
|
||||
mainClass = 'Exam2_Practice_CalebFontenot.App'
|
||||
}
|
||||
|
||||
tasks.named('test') {
|
||||
// Use JUnit Platform for unit tests.
|
||||
useJUnitPlatform()
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* This Java source file was generated by the Gradle 'init' task.
|
||||
*/
|
||||
package Exam2_Practice_CalebFontenot;
|
||||
|
||||
public class App {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("hi");
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package Exam2_Practice_CalebFontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class PrintArrayReversedEven {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
printRE(new int[] {1, 2, 3});
|
||||
printRE(new int[2]);
|
||||
printRE(new int[] {2, 4, 7, 8});
|
||||
}
|
||||
public static void printRE(int[] array) {
|
||||
int arrayLength = 0;
|
||||
for (int i = 0; i < array.length - 1; i++) {
|
||||
// determine array length.
|
||||
if (array[i] % 2 == 0) {
|
||||
arrayLength++;
|
||||
}
|
||||
}
|
||||
// Now create the return array.
|
||||
int[] returnArray = new int[arrayLength];
|
||||
int arrayI = 0;
|
||||
for (int i = 0; i < array.length - 1; i++) {
|
||||
if (array[i] % 2 == 0) {
|
||||
// Add even numbers to array.
|
||||
returnArray[arrayI] = array[i];
|
||||
arrayI++;
|
||||
}
|
||||
}
|
||||
// Reverse items in the array.
|
||||
int[] reversedReturnArray = new int[arrayI];
|
||||
int reverseArrayIterable = arrayI - 1;
|
||||
for (int i = 0; i < returnArray.length - 1; i++) {
|
||||
reversedReturnArray[reverseArrayIterable] = returnArray[i];
|
||||
reverseArrayIterable--;
|
||||
}
|
||||
// Now print the array.
|
||||
for (int i = 0; i > reversedReturnArray.length - 1; i++) {
|
||||
System.out.print(reversedReturnArray[i] + " ");
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* This Java source file was generated by the Gradle 'init' task.
|
||||
*/
|
||||
package Exam2_Practice_CalebFontenot;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class AppTest {
|
||||
@Test void appHasAGreeting() {
|
||||
App classUnderTest = new App();
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user