From 2cac9a96699b1ba5b315c76e1c2f0842db4b1f50 Mon Sep 17 00:00:00 2001 From: MannyMonocle Date: Tue, 29 Oct 2019 17:29:14 -0400 Subject: [PATCH] completed --- .idea/compiler.xml | 16 +++++ .idea/misc.xml | 13 +++++ .idea/modules.xml | 8 +++ .idea/vcs.xml | 6 ++ PlaylistChallenge.iml | 16 +++++ src/main/java/io/zipcoder/Music.java | 55 +++++++++++++++++- target/classes/io/zipcoder/Music.class | Bin 0 -> 1518 bytes .../test-classes/io/zipcoder/MusicTest.class | Bin 0 -> 1381 bytes 8 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 .idea/compiler.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 PlaylistChallenge.iml create mode 100644 target/classes/io/zipcoder/Music.class create mode 100644 target/test-classes/io/zipcoder/MusicTest.class diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..2bb69ef --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d30d09e --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..5103107 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/PlaylistChallenge.iml b/PlaylistChallenge.iml new file mode 100644 index 0000000..0ddf51c --- /dev/null +++ b/PlaylistChallenge.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/io/zipcoder/Music.java b/src/main/java/io/zipcoder/Music.java index 180c65c..f83f4b2 100644 --- a/src/main/java/io/zipcoder/Music.java +++ b/src/main/java/io/zipcoder/Music.java @@ -1,5 +1,7 @@ package io.zipcoder; +import java.util.Arrays; + public class Music { private String[] playList; @@ -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; } } diff --git a/target/classes/io/zipcoder/Music.class b/target/classes/io/zipcoder/Music.class new file mode 100644 index 0000000000000000000000000000000000000000..edee04ff76c1ab10838516514e792184893c3cc6 GIT binary patch literal 1518 zcmaJ>OK%%h7(I79o@-BrIEfiIX(^Px;v`KCX=~az6w*RUD)%9!3JZk9#F>T(&Nv#6 zQ^JN#7HpB&6$y!lvg9EsZ6)#pSn>lvt*S1l#HuS6gmY)?cmh=ybLZUealY5R_t$^! zZUJ~17fo0=l0^@WN(`GQVkC=EjF~uwaTCW;Qs|`~nocO~35k;urvx&qb!WZmHA8{? zJJn@p%_-F#f2lMV2A;oE5iq7a-wV$Q6pByKkIW0`=NpTzK(6Zf?&a3Xf*V|O7V4A? zR2wy?KJNsc+P8&z_`cUF-8t*T+$NemL*cTg;P2 zWK5>D-VEIpDjF?v*l{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