Skip to content
Open

Done #18

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
32 changes: 31 additions & 1 deletion src/main/java/io/zipcoder/Music.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,40 @@ public class Music {
private String[] playList;

public Music(String[] playList){

this.playList = playList;
}

public Integer selection(Integer startIndex, String selection){
return null;
Integer upButton = pressUpButton(startIndex);
Integer downButton = pressDownButton(startIndex);

if (upButton < downButton){
return upButton;
}

return downButton;
}

private Integer pressDownButton(Integer startIndex) {
Integer secondCount = 0;
for (int i = startIndex; i != playList.length - 1; i--){
if (i == 0){
i = playList.length;
secondCount++;
}else{
secondCount++;
}
}
return secondCount;
}

private Integer pressUpButton(Integer startIndex) {
Integer count = 0;
for (int i = startIndex; i < playList.length; i++){
count++;
}
return count;
}
}