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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
.idea/**/tasks.xml
.idea/dictionaries

target/
.idea/
*.iml

# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
Expand Down Expand Up @@ -46,4 +50,4 @@ atlassian-ide-plugin.xml
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
fabric.properties
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<artifactId>PlaylistChallenge</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
Expand Down
20 changes: 19 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,24 @@ public Music(String[] playList){
}

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

int count = 0;
for (int i = startIndex; !playList[i].equals(selection); i++) {
if(i == playList.length - 1) {
i = -1;
}
count++;
}

int revCount = 0;
for (int i = startIndex; !playList[i].equals(selection); i--) {
if(i == 0) {
i = playList.length;
}
revCount++;
}

if(count < revCount) { return count; }
else { return revCount; }
}
}