From 37c9a61efc178414537ffaec98b25a8accf2c356 Mon Sep 17 00:00:00 2001 From: ushanil Date: Tue, 29 Oct 2019 20:07:15 -0400 Subject: [PATCH] done with lab --- src/main/java/io/zipcoder/Music.java | 77 +++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/zipcoder/Music.java b/src/main/java/io/zipcoder/Music.java index 180c65c..4944de0 100644 --- a/src/main/java/io/zipcoder/Music.java +++ b/src/main/java/io/zipcoder/Music.java @@ -5,10 +5,83 @@ public class Music { private String[] playList; public Music(String[] playList){ + this.playList = playList; } - public Integer selection(Integer startIndex, String selection){ - return null; + public int MoveForward(int currentPosition) + { + int nextPosition = 0; + if (currentPosition != playList.length-1) + { + nextPosition = currentPosition+1; + } + else nextPosition = 0; + + return nextPosition; + + } + + public int MoveBackward(int currentPosition) + { + int nextPosition = 0; + if (currentPosition != 0) + { + nextPosition = currentPosition-1; + } + else nextPosition = playList.length-1; + + return nextPosition; + } + + public Integer selection(Integer startIndex, String selection) + { + Integer noClickForward = 0; + Integer noClickBackward = 0; + //forward + int currentIndex = startIndex; + int nextIndex = MoveForward(currentIndex); + for (int i=0; inoClickBackward) + { + return noClickBackward; + } + else { + return noClickForward; + } + } }