diff --git a/Humans and Superhumans.xml b/Humans and Superhumans.xml new file mode 100644 index 0000000..e69de29 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..16604de --- /dev/null +++ b/pom.xml @@ -0,0 +1,33 @@ + + + 4.0.0 + + crame.randall + ReusingClassesLabs + 1.0-SNAPSHOT + + + + junit + junit + 4.12 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.0 + + 1.8 + 1.8 + + + + + + \ No newline at end of file diff --git a/src/main/java/ReusingClassesLabs/Main.java b/src/main/java/ReusingClassesLabs/Main.java new file mode 100644 index 0000000..4ca9bf5 --- /dev/null +++ b/src/main/java/ReusingClassesLabs/Main.java @@ -0,0 +1,32 @@ +package ReusingClassesLabs; + + +/** + * Created by randallcrame on 1/18/17. + */ +public class Main { + public static void main (String[] args){ + RotateArray object = new RotateArray(); + + int array[] = {1,2,3,4,5}; + String original = "Original: ", rotated ="Rotated: "; + for(int i:array) original += array[i-1] + " "; + + + object.rotateArray(array, 2); + for(Integer j:array) rotated+=array[j-1]+" "; + + for(int i = 0; i < array.length; i++) { + System.out.println(array[i]); + } + + + System.out.println(original+"\n"+rotated); + + + for(int i: array) { + System.out.println(i) + i = array[..]; + } + } +} diff --git a/src/main/java/ReusingClassesLabs/RotateArray.java b/src/main/java/ReusingClassesLabs/RotateArray.java new file mode 100644 index 0000000..60241a1 --- /dev/null +++ b/src/main/java/ReusingClassesLabs/RotateArray.java @@ -0,0 +1,24 @@ +package ReusingClassesLabs; + +import java.util.ArrayList; + +/** + * Created by randallcrame on 1/18/17. + */ +public class RotateArray extends ArrayList { + //private int currentArrayHolder, temporaryValue; + + public void rotateArray(int array[], int rotate) { + int currentArrayHolder, temporaryValue; + + for (int i = 0; i < rotate; i++) { + temporaryValue = array[0]; + for (currentArrayHolder = 0; currentArrayHolder < array.length-1; currentArrayHolder++) { + array[currentArrayHolder] = array[currentArrayHolder+1]; + } + array[array.length-1] = temporaryValue; + + + } + } +} diff --git a/src/test/java/ReusingClassesLabsTest/RotateArrayTest.java b/src/test/java/ReusingClassesLabsTest/RotateArrayTest.java new file mode 100644 index 0000000..487f1b5 --- /dev/null +++ b/src/test/java/ReusingClassesLabsTest/RotateArrayTest.java @@ -0,0 +1,9 @@ +package ReusingClassesLabsTest; + +/** + * Created by randallcrame on 1/18/17. + */ +public class RotateArrayTest { + //No Test Required + +}