From fe37d32030c76ffa2dbebbf3a904bf8536cef08c Mon Sep 17 00:00:00 2001
From: vaidehi4321 <56602405+vaidehi4321@users.noreply.github.com>
Date: Sat, 26 Oct 2019 14:16:58 -0400
Subject: [PATCH] playList 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 | 43 ++++++++++++++++--
target/classes/io/zipcoder/Music.class | Bin 0 -> 905 bytes
.../test-classes/io/zipcoder/MusicTest.class | Bin 0 -> 1381 bytes
8 files changed, 98 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..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..6bd5f36 100644
--- a/src/main/java/io/zipcoder/Music.java
+++ b/src/main/java/io/zipcoder/Music.java
@@ -4,11 +4,46 @@ 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) {
+
+
+
+ int leftCount=0;
+ int rightCount=0;
+ //right counting
+ int i=startIndex;
+ while(playList[i]!=selection){
+ i++;
+ rightCount++;
+ if(i==playList.length){
+ i=0;
+ }
+
+ }
+ //left counting
+ int j=startIndex;
+ while(playList[j]!=selection){
+ j--;
+ leftCount++;
+
+ if(j<0){
+ j=playList.length-1;
+ }
+
+ }
+ if(leftCount<=rightCount){
+ return leftCount;
+ }
+
+
+
+
+ return rightCount;
}
-}
+}
\ 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..bf625c98eab2d34797f5e184f4d645c6b22cbc5e
GIT binary patch
literal 905
zcmZuvO-~b16g_WdI@1nSK3f5)fFQO&Y{aAsQDV}B(4@)&(uFQ`T88q-I3?35QP=$$
zE=-JJtBGH6!4L3X=*o?M!Ft}bwoN2WZ{I!lzI)EOuiyWCI|pzZIU6SC5{MyV;~M5w
zSg^2Y;krQl#B*MjWiu3*d{RDkPMy5x`1Sl=7)ZaqDPZ1{z6`en(%B2@xr%^MY#g`(
zqh;y4k6O>GZm{oEJt7n3M$PdmP9Rm@1C8)VHc3{Njr=QlQsdnq|FG4RHIgNouIJW5
z+3*GKW{2dI{Lrnt!R8RuQ?zU7W?MVAA#gIe-OG#LWTUbuw23C@|iLAi*e_jQ~2AX!O
z$22XVXVp5#2Zf$kzLNCAisQA&$0q8sPF1#hsGg;C(F(B0_cr25b`qs(|On#zS>4CCFIVuU>wYp%Yf
z7mT&f&RIP!)MiF)rfQpQo1L~UQs(Q5
z@PNxHVhKA~#y+xmj2xaKAKBdL8tB_}IdhWsXo^Os$f2PY&DY8Gj0|b6X@oPTd5V$a
O4%yONy})dw@akWdO}e)L
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