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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ atlassian-ide-plugin.xml
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
fabric.properties

# Apple files
*.DS_Store
48 changes: 47 additions & 1 deletion src/main/java/io/zipcoder/Music.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,52 @@ public Music(String[] playList){
}

public Integer selection(Integer startIndex, String selection){
return null;

int counterCurrentLocation = 0;
int counterUpArrow = 0;
int counterDownArrow = 0;
int counterNumberSteps = 0;

// up arrow direction
counterCurrentLocation = playList.length - 1;
if (startIndex != playList.length - 1) counterCurrentLocation = startIndex + 1;
counterUpArrow ++;


while (counterCurrentLocation != startIndex){
if (selection.equals(playList[counterCurrentLocation])) {
break;
}
// if we hit the end of the loop, reset and start from beginning of the list
if (counterCurrentLocation >= playList.length - 1){
counterCurrentLocation = 0;
}
counterCurrentLocation ++;
counterUpArrow ++;
}



// down arrow direction
counterCurrentLocation = 0;
if (startIndex != 0) counterCurrentLocation = startIndex - 1;
counterDownArrow ++;
counterNumberSteps = counterUpArrow;

while (counterCurrentLocation != startIndex){
if (selection.equals(playList[counterCurrentLocation])) {
break;
}
// if we hit the end of the loop, reset and start from beginning of the list
if (counterCurrentLocation <= 0){
counterCurrentLocation = playList.length;
}
counterCurrentLocation --;
counterDownArrow ++;
}

if (counterDownArrow < counterUpArrow) counterNumberSteps = counterDownArrow;

return counterNumberSteps;
}
}