diff --git a/.idea/misc.xml b/.idea/misc.xml index e8942bd..b2526f7 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -7,7 +7,7 @@ - - + + \ No newline at end of file diff --git a/PlaylistChallenge.iml b/PlaylistChallenge.iml index 54ddd53..0ddf51c 100644 --- a/PlaylistChallenge.iml +++ b/PlaylistChallenge.iml @@ -5,7 +5,6 @@ - diff --git a/src/main/java/io/zipcoder/Music.java b/src/main/java/io/zipcoder/Music.java index 180c65c..b86b734 100644 --- a/src/main/java/io/zipcoder/Music.java +++ b/src/main/java/io/zipcoder/Music.java @@ -4,11 +4,72 @@ public class Music { private String[] playList; + + //String[] n=songs | Integer k=index of the song | String q= the name of the song you wish to switch to + //identify the Occurences + //get the length going forward + //get the length going backwards + public Music(String[] playList){ + + this.playList = playList; + } public Integer selection(Integer startIndex, String selection){ - return null; + + return compareForwardBackward(startIndex, selection); + } + + + + + + + //method to go forward + public Integer forwardButton(Integer startingIndex, String selection){ + + Integer counter = 0; + + for(Integer i = Integer.valueOf(playList[startingIndex]); i < playList.length; i++){ + counter++; + if(playList.length-1 == startingIndex){ + startingIndex = 0; + }else{ + startingIndex++; + } + } + return counter; + } + + + + + //method to go backwards + public Integer backwardsButton(Integer startingIndex, String selection){ + + Integer counter = 0; + + for(Integer i = Integer.valueOf(playList[startingIndex]); i