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.

13 changes: 13 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>
55 changes: 54 additions & 1 deletion src/main/java/io/zipcoder/Music.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.zipcoder;

import java.util.Arrays;

public class Music {

private String[] playList;
Expand All @@ -9,6 +11,57 @@ public Music(String[] playList){
}

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

String[] upButton = new String[playList.length];
String[] downButton = new String[playList.length];


// build downButton array

int w = 0;
for (int i = startIndex; i < playList.length; i++){
downButton[w] = playList[i];
w++;
}

//int w = playList.length - startIndex;

for (int i = 0; w < playList.length; i++) {
downButton[w] = playList[i];
w++;
}



// build upButton array

int x = 0;
for (int j = startIndex; j >= 0; j--){
upButton[x] = playList[j];
x++;
}

for(int j = playList.length -1; j > startIndex; j--){
upButton[x] = playList[j];
x++;
}

//print arrays
/*
System.out.println(Arrays.toString(upButton));
System.out.println(Arrays.toString(downButton));
*/

//test which index is lower

int ans;

if(Arrays.asList(downButton).indexOf(selection) <= Arrays.asList(upButton).indexOf(selection)){
ans = Arrays.asList(downButton).indexOf(selection);
} else {
ans = Arrays.asList(upButton).indexOf(selection);
}

return ans;
}
}
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.