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
16 changes: 16 additions & 0 deletions .idea/compiler.xml

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

11 changes: 11 additions & 0 deletions .idea/misc.xml

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

8 changes: 8 additions & 0 deletions .idea/modules.xml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

16 changes: 16 additions & 0 deletions PlaylistChallenge.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
<output url="file://$MODULE_DIR$/target/classes" />
<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/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<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" />
</component>
</module>
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
<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
32 changes: 28 additions & 4 deletions src/main/java/io/zipcoder/Music.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,35 @@ public class Music {

private String[] playList;

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

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

Integer search = 0;
Integer upCount;
Integer downCount;
Integer endOfArray = playList.length;

if (startIndex == endOfArray) {upCount = 0;}
else {upCount = startIndex +1;}
if (startIndex == 0) {downCount = endOfArray - 1;}
else {downCount = startIndex -1;}


if (playList[startIndex] == selection) {
//return search;
} else {search = 1;
while (playList[upCount] != selection && playList[downCount] != selection) {
//search++;
if (upCount == endOfArray - 1) {upCount = 0;} else {upCount++;}
if (downCount == 0) {downCount = endOfArray - 1;} else {downCount--;}
search++;
}
}

return search;

}
}
}
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.