From 32fc5ea194392defb42e5c72a99851eaccfa1383 Mon Sep 17 00:00:00 2001 From: Owen Murphy Date: Fri, 2 Mar 2018 15:48:27 -0500 Subject: [PATCH] head hurts --- PlaylistChallenge.iml | 2 ++ pom.xml | 5 ++++ src/main/java/io/zipcoder/Music.java | 28 ++++++++++++++++-- target/classes/io/zipcoder/Music.class | Bin 0 -> 991 bytes .../test-classes/io/zipcoder/MusicTest.class | Bin 0 -> 1381 bytes 5 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 target/classes/io/zipcoder/Music.class create mode 100644 target/test-classes/io/zipcoder/MusicTest.class diff --git a/PlaylistChallenge.iml b/PlaylistChallenge.iml index 54ddd53..235aa41 100644 --- a/PlaylistChallenge.iml +++ b/PlaylistChallenge.iml @@ -13,5 +13,7 @@ + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index bbd82c1..cd17122 100644 --- a/pom.xml +++ b/pom.xml @@ -16,5 +16,10 @@ 4.12 test + + junit + junit + RELEASE + \ 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..ae19fbb 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){ - this.playList = playList; + public Music(String[] playList){ + this.playList = playList; } public Integer selection(Integer startIndex, String selection){ - return null; + int lengthOfList = playList.length; + int goForward = 0; + int goBack = 0; + int Index = 0; + + //go through playList, song=index + for(int i = 0; i < playList.length; i++){ + if (selection.equals(playList[i])){ + Index = i; + + // + if(Index > startIndex) { + goForward = Index - startIndex; + + if (Index < lengthOfList - 1) { + goBack = lengthOfList - 1 - Index; + } + } + } + } + if (goForward < goBack){ + return goBack; + }else return goForward; } } diff --git a/target/classes/io/zipcoder/Music.class b/target/classes/io/zipcoder/Music.class new file mode 100644 index 0000000000000000000000000000000000000000..f8c0cd1bbafa87bdcebee1c77312a8c9800e9abf GIT binary patch literal 991 zcm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