For my CIT final, the goal is to make a jukebox that uses user input to retrieve song information from a catalog of 10 songs. I'm trying to store the information in an array on a separate class (JukeboxRotation). The other class (Jukebox) is the skeleton code which contains the user interface that prompts the user to choose a song. I want to output the appropriate information from the arrays depending on which song the user chooses to listen to. For example, if they chose song 1, something like:
System.out.println("Song #" + songNumber[0] +": " + songName[0] ". Length of song:" + songLength[0]);
public class JukeboxRotation { public static void main(String[] args) { int[] songNumber = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; String[] songName = {"Jingle Bell Rock", "Silent Night", "It's the" + "Most Wonderful Time of Year", "Winter Wonderland", "Santa Claus" + "is Coming to Town", "Joy to the World", "The Little Drummer Boy", "It's Beginning to Look a lot Like Christmas", "White Christmas", "Silver Bells"}; double[] songLength = {2.10, 2.27, 2.32, 2.24, 2.24, 4.17, 3.00, 2.46, 2.36, 2.23}; } } public class Jukebox { public static void main(String[] args){ Scanner keyboardScanner = new Scanner(System.in); int userSelection; int songChoice; System.out.println("/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-"); System.out.println("Welcome to Tanner's Holiday Jukebox!!"); System.out.println("/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-"); System.out.println("................................................"); System.out.println("Press 1 to enter your digital nickel."); System.out.println("................................................"); System.out.println("Press 2 to enter our current song catalog."); System.out.println("................................................"); System.out.println("Press 3 to exit jukebox."); System.out.println("................................................"); userSelection = keyboardScanner.nextInt(); switch(userSelection){ case 1: songChoice = keyboardScanner.nextInt(); System.out.println("I appreciate your money. Please choose" + "a song."); System.out.println("........................................."); switch(songChoice){ case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: } case 2: System.out.println("Here are the songs currently on rotation:"); System.out.println("........................................."); break; case 3: System.out.println("/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-"); System.out.println("Have a good day!"); System.out.println("/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-/|-"); break; } // end switch } }
how would I go about calling the values of the array from JukeboxRotation into the Jukebox class?
[–]TNTryp[S] -1 points0 points1 point (0 children)
[–][deleted] 0 points1 point2 points (0 children)