From 9f4b2c3d40aa4779866f5af75c286758fc87383b Mon Sep 17 00:00:00 2001 From: Emma Beech Date: Fri, 14 Feb 2020 08:59:05 -0500 Subject: [PATCH] done --- .idea/compiler.xml | 16 ++++++++++ .idea/misc.xml | 11 +++++++ .idea/modules.xml | 8 +++++ .idea/vcs.xml | 6 ++++ PlaylistChallenge.iml | 16 ++++++++++ pom.xml | 12 ++++++++ src/main/java/io/zipcoder/Music.java | 28 ++++++++++++++++-- target/classes/io/zipcoder/Music.class | Bin 0 -> 947 bytes .../test-classes/io/zipcoder/MusicTest.class | Bin 0 -> 1381 bytes 9 files changed, 94 insertions(+), 3 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..f3891de --- /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..4361200 --- /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..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..4e3316b --- /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..746fa88 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,18 @@ io.zipcoder PlaylistChallenge 1.0-SNAPSHOT + + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + + diff --git a/src/main/java/io/zipcoder/Music.java b/src/main/java/io/zipcoder/Music.java index 180c65c..c88aa83 100644 --- a/src/main/java/io/zipcoder/Music.java +++ b/src/main/java/io/zipcoder/Music.java @@ -4,11 +4,33 @@ 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; +// String[] playlist = {"dancinginthedark","rio","liveoak","liveoak"}; +// Music music = new Music(playlist); +// Integer startingIndex = 0; +// String selection = "liveoak"; +// Integer expected = 1; +// Integer actual = music.selection(startingIndex, selection); +// Assert.assertEquals(expected, actual); + +// def distance(len_my_list, idx_1, idx_2): +// dist = abs(idx_1 - idx_2) +// return min(len_my_list - dist, dist) + public Integer selection(Integer startIndex, String selection) { + int current = 0; + + + for (int i = 0; i < playList.length; i++) { + if (playList[i].equals(selection)) { + current = Math.abs(startIndex - i); + + } + } + + + return Integer.min(playList.length - current, current); } } diff --git a/target/classes/io/zipcoder/Music.class b/target/classes/io/zipcoder/Music.class new file mode 100644 index 0000000000000000000000000000000000000000..6f84586ff0eb780ad9f58b204a96abb77a784cac GIT binary patch literal 947 zcmZuwOHUI~6#i~!%FtmbFIyF?N_|ZWQbj~#g^dYGlU5crEOd1{9pU0IthKEx61+}4^^n*b%CsViodWW zU_NR!eSwLp3jN33y@nq>k&S?s>1xZ9!Iq4a*84^?-ccPEtEyJ%jcR+$jY_p{M|muk z>iB{0#i|twJaC8TRKnQb_M`HUsn4)5Wcn8+AQZoffZd5@6j#Eg|4P>!^fw5d9Zbf^IJ;gO7-AYfh_I2jwbNvu1rwtwRd~hi~ zK!JoF18)i59gI_^scleC@U)9xA&LuMkoeS#nV?L=ptNB2FjAPLmOYNf6sD;$uZPOL zVg_gWn4cMwq;JhwH&)GzS)}3UJ@Wd@n9GX?Fy0}(Z~*$6he)o!HN}TNKYC%gX6_Ip zhp;{pz<{PPixJAR1f8Wmha4`z<$a02jHa~0Vo4N`Avu%!+6lQeW}PD`ZJWV)A|y~| YW|qivw2r~}g`^Pqp9Bzu)ziuS1sy`ikpKVy 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..b23c7991d6b696f7ead1ef723baab9fc8739d78f GIT binary patch literal 1381 zcmcIjSx*yD6#j-zJ7X;s1_kO;6&G5zio3-PjYg6xi6u=MpKhnua&ef!SrGkKz6jCi zlTZFA<9DHpTIp>HPTl`5S=ic$CEuN*2mCrff{xn6WWyVJ-^`l`O7c zUPo86xQ6RCZrHeKGHo+puVS7a0~7|2J`lWwd6Unk}b*c+aB@2My@ zF!HLlCN@RI6Mm;sk3;2m*pXh>?RlWzy3ScEYvm;AQe(p5c(B|nxO8M5lgKC9N< ztJo*8<<3}lKZH3=pTjU5!u%C$z-Z}^{pr8ZaL;9TC1ltXULu!Y>$atG-%5H*tCkK)_ocea zJG^g@d06N}?`FykoX0VKPWqPu&A{PvgtrP$gJ*hb z8^%Wl131oSW;dC^3C6j-0*qpeHv{8r9@uUE4wIiC@W}d#fo94{)tjbc)|+W3U2kTb zOuhC6R&#nA_H%OwM_xFYs+nd`P0!30%umQxGlg^^vxB2O<_XwDJc{cm409Akq={v-wn(QJ zh^GBsMA3nu^ZQUGcxV JyG)Oq%rAlTDFy%l literal 0 HcmV?d00001