From 029de499a6a2d7bb1c09c09a64a941530cff741f Mon Sep 17 00:00:00 2001 From: Maira Botelho Date: Thu, 24 Oct 2019 17:11:43 -0400 Subject: [PATCH] done --- .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 | 40 +++++++++++++++++- target/classes/io/zipcoder/Music.class | Bin 0 -> 1018 bytes .../test-classes/io/zipcoder/MusicTest.class | Bin 0 -> 1381 bytes 8 files changed, 98 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..2545dc7 --- /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..421755f 100644 --- a/src/main/java/io/zipcoder/Music.java +++ b/src/main/java/io/zipcoder/Music.java @@ -9,6 +9,44 @@ public Music(String[] playList){ } public Integer selection(Integer startIndex, String selection){ - return null; + + int counter1 = 0; + int counter2 = 1; + int result = 0; + + for (int x = startIndex; x < playList.length; x++){ + + if (playList[x].equals(selection) ){ + break; + } + + counter1++; + } + + result = counter1; + + if(startIndex == 0){ + + for (int x = playList.length - 1; x > 0; x--){ + + if (playList[x].equals(selection) ){ + break; + } + + counter2++; + + } + + if(counter1 > counter2){ + result = counter2; + }else{ + result = counter1; + } + } + + + + + return result; } } diff --git a/target/classes/io/zipcoder/Music.class b/target/classes/io/zipcoder/Music.class new file mode 100644 index 0000000000000000000000000000000000000000..7ec80e88fe3e2cc7d04d5ff22acc6374bff662b3 GIT binary patch literal 1018 zcmZuwO-~b16g_V`ooUD6y90huKM=4jNCUyzHl2{R&ndaH|}ngy+Ls~YPeM{ zOE(nNC*!nBFo zm=PHGPqje*x$7&N+mtVm$Vp=d&M(@^$j0@w86S^2cI zx#=UQ@1Qkd9wx-0CYmR|vn}v@$j%t9ZpqFM-I`Q3oitDWWG(d*3`;E~o6tDHO8!9d zGYKe=GFFk{*~6?CNfJ+y>O~A;lJz`BFwJ}pmvI-PSU?sJ__tc7aT^%JGfco{UL$e` z1%yPu!kyTPRZi-~I45Oj@*|>J5rv=Ga{!B$326qmjF5wZx7?ngwMp#b5+iAE#Qhmo K1g^xqNB;q|*3b$7 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