From c2824c6582615bebddbd542feb55cf3aa06b12ed Mon Sep 17 00:00:00 2001 From: chipfody <60615532+chipfody@users.noreply.github.com> Date: Sun, 16 Feb 2020 20:30:45 -0500 Subject: [PATCH] Played out --- .idea/compiler.xml | 16 +++++++++ .idea/misc.xml | 11 ++++++ .idea/modules.xml | 8 +++++ .idea/vcs.xml | 6 ++++ PlaylistChallenge.iml | 16 +++++++++ pom.xml | 5 +++ src/main/java/io/zipcoder/Music.java | 32 +++++++++++++++--- target/classes/io/zipcoder/Music.class | Bin 0 -> 1053 bytes .../test-classes/io/zipcoder/MusicTest.class | Bin 0 -> 1381 bytes 9 files changed, 90 insertions(+), 4 deletions(-) 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..45391e4 --- /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..602a0dd --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,11 @@ + + + + + + + \ 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..94a25f7 --- /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/pom.xml b/pom.xml index bbd82c1..691f920 100644 --- a/pom.xml +++ b/pom.xml @@ -8,6 +8,11 @@ PlaylistChallenge 1.0-SNAPSHOT + + 1.8 + 1.8 + + diff --git a/src/main/java/io/zipcoder/Music.java b/src/main/java/io/zipcoder/Music.java index 180c65c..8317c44 100644 --- a/src/main/java/io/zipcoder/Music.java +++ b/src/main/java/io/zipcoder/Music.java @@ -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; + } -} +} \ No newline at end of file diff --git a/target/classes/io/zipcoder/Music.class b/target/classes/io/zipcoder/Music.class new file mode 100644 index 0000000000000000000000000000000000000000..4d480a0e61de4402f15848d128d901e8ec59e570 GIT binary patch literal 1053 zcmZuwOHUI~6#i~IkIq==3(=tpB0dU;jV@daL}N%uN@`hPYN{qWv;$mHXUKGlqC5YC ziE-sZY20bzD=yf%@dvndZDRNd;<>kjG@+T~&N<)t&g;7~KmLB(1#krg6B_acRGcz# z8l&PE({V<}I74Ey>1>yID`d#sD{nYkPO<5DYsKX-;NIFSgEq%K9$se{F7$~{RvDCe zzu_{Z%G`4+?MEwaaNAjF5|SQ&S1J;V`=qf5IEc9Ec@-C?k;e#t0`BwERvHja5f1Y2^|wjoWuDfF5n_V z=E%wn>BDwQD;u;sL%bkV%^U`zwP>p?r`dLwR>ftM`Y)c~URV_@S*L_?x^|5|1BRHG zh^!dd2247Sk+(p8jNazd7qF@6Pl$bxoFtuth|{SK7GqdZxaQMEKO z-J0wrgODBGI>aE-027d7;Fkdan`@Bn!{ zqaX1dMSo%pe=s4l?vrwP(l1Ln3g*ZfB1;u&{?~ku>f}gkfu-e*sQ8T&gvF`P_b7J} TZ=&23eo@yPeFqGdoO0wJ*o)eu literal 0 HcmV?d00001 diff --git a/target/test-classes/io/zipcoder/MusicTest.class b/target/test-classes/io/zipcoder/MusicTest.class new file mode 100644 index 0000000000000000000000000000000000000000..3a5845d28504d1de96f858cf44e777177bdaa963 GIT binary patch literal 1381 zcmcIjSx*yD6#j-zJ3}c21_3LJiVKvjf_p&}j7E|wi6tbBPnYSnTpVU_7F_<7FG@7} zu4d1>$qX#rj1)RZdNAPeu9iS+ct&!ws?JG2>JM zS9qHuRQldbn(?-Z3=CCNPZ%sRnjg!C3|ZBA%&K*_ zDvn8P`F4-8WS#zn8z;guP1?v~n8ktps7Cw3BdBrBj_P7|2$G zBy{CtrKgoY9>Sca&!GiZ)S>{xQHHpPWqPu&A{QapSKcEgJ*i` z6O0cGI&g;1%waNv0miwb0t{k^Hv?zc+;Q0a9VS0PVAcAHj#|n|RcoeWR%>Y|U9DxD zOtta_R&Dwd?5E}dI-fb2vYBR3PS4C1%#X;HGlg^^bAYZE^EhlGcA-Gtadcw>c}!FM zJmr@ue1+^<)srLUrm6yp>^Mhtfj?w8Q zqG`XEc^bI#S9dw>u3NjyYj^oJcd0{n`Ld~P{@dLUwVow=ff~DFXli literal 0 HcmV?d00001