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
2 changes: 2 additions & 0 deletions PlaylistChallenge.iml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
</module>
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,10 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
</dependency>
</dependencies>
</project>
28 changes: 25 additions & 3 deletions src/main/java/io/zipcoder/Music.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,33 @@ public class Music {

private String[] playList;

public Music(String[] playList){
this.playList = playList;
public Music(String[] playList){
this.playList = playList;
}

public Integer selection(Integer startIndex, String selection){
return null;
int lengthOfList = playList.length;
int goForward = 0;
int goBack = 0;
int Index = 0;

//go through playList, song=index
for(int i = 0; i < playList.length; i++){
if (selection.equals(playList[i])){
Index = i;

//
if(Index > startIndex) {
goForward = Index - startIndex;

if (Index < lengthOfList - 1) {
goBack = lengthOfList - 1 - Index;
}
}
}
}
if (goForward < goBack){
return goBack;
}else return goForward;
}
}
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.