Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Reusing_Classes_Labs
Submodule Reusing_Classes_Labs added at d82ae4
21 changes: 21 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>reynoldstitko.gillian</groupId>
<artifactId>RotatingArrays</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>

</dependencies>

</project>
50 changes: 50 additions & 0 deletions src/main/java/reynoldstitko/gillian/RotateArrays.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package reynoldstitko.gillian;

import java.util.ArrayList;
import java.util.*;

/**
* Created by gillianreynolds-titko on 1/18/17.
*/
public class RotateArrays extends ArrayList {

public void rotateArray(ArrayList<Integer> inputArray, int k){
System.out.println("Your input array is: "+ inputArray);
if(k > inputArray.size()){
System.out.print("Choose k less than or equal to your array size");
return;
}

for(int i=0; i <k; i++){
inputArray.add(inputArray.size(), inputArray.get(0));
inputArray.remove(0);
}
System.out.println("Your rotated array is: "+ inputArray);
}

public static void main(String[] arg){

RotateArrays tester3 = new RotateArrays();
RotateArrays tester4 = new RotateArrays();
tester3.add(1);
tester3.add(2);
tester3.add(3);
tester3.add(4);
tester3.add(5);
tester3.add(6);
tester3.rotateArray(tester3, 3);

tester4.add(1);
tester4.add(2);
tester4.add(3);
tester4.add(4);
tester4.add(5);
tester4.add(6);
tester4.add(7);
tester4.add(8);
tester4.rotateArray(tester4, 6);

}


}