diff --git a/PlaylistChallenge.iml b/PlaylistChallenge.iml
index 54ddd53..235aa41 100644
--- a/PlaylistChallenge.iml
+++ b/PlaylistChallenge.iml
@@ -13,5 +13,7 @@
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index bbd82c1..cd17122 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,5 +16,10 @@
4.12
test
+
+ junit
+ junit
+ RELEASE
+
\ No newline at end of file
diff --git a/src/main/java/io/zipcoder/Music.java b/src/main/java/io/zipcoder/Music.java
index 180c65c..ae19fbb 100644
--- a/src/main/java/io/zipcoder/Music.java
+++ b/src/main/java/io/zipcoder/Music.java
@@ -4,11 +4,33 @@ public class Music {
private String[] playList;
- public Music(String[] playList){
- this.playList = playList;
+ public Music(String[] playList){
+ this.playList = playList;
}
public Integer selection(Integer startIndex, String selection){
- return null;
+ int lengthOfList = playList.length;
+ int goForward = 0;
+ int goBack = 0;
+ int Index = 0;
+
+ //go through playList, song=index
+ for(int i = 0; i < playList.length; i++){
+ if (selection.equals(playList[i])){
+ Index = i;
+
+ //
+ if(Index > startIndex) {
+ goForward = Index - startIndex;
+
+ if (Index < lengthOfList - 1) {
+ goBack = lengthOfList - 1 - Index;
+ }
+ }
+ }
+ }
+ if (goForward < goBack){
+ return goBack;
+ }else return goForward;
}
}
diff --git a/target/classes/io/zipcoder/Music.class b/target/classes/io/zipcoder/Music.class
new file mode 100644
index 0000000..f8c0cd1
Binary files /dev/null and b/target/classes/io/zipcoder/Music.class differ
diff --git a/target/test-classes/io/zipcoder/MusicTest.class b/target/test-classes/io/zipcoder/MusicTest.class
new file mode 100644
index 0000000..3a5845d
Binary files /dev/null and b/target/test-classes/io/zipcoder/MusicTest.class differ