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
4 changes: 2 additions & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion PlaylistChallenge.iml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
Expand Down
63 changes: 62 additions & 1 deletion src/main/java/io/zipcoder/Music.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 <playList.length; i++){

counter++;
if(startingIndex==0){
startingIndex = playList.length-1;
}else{
startingIndex--;
}
}
return counter;
}

public Integer compareForwardBackward(Integer startingIndex, String selection){

if(forwardButton(startingIndex,selection) < backwardsButton(startingIndex,selection)){
return forwardButton(startingIndex,selection);
}
return forwardButton(startingIndex, selection);
}


}
Binary file added target/classes/io/zipcoder/Music.class
Binary file not shown.
Binary file added target/test-classes/io/zipcoder/MusicTest.class
Binary file not shown.