Concept explainers
Explanation of Solution
Given:Â The class named MusicOrganizer.
To find: A way to play various tracks in random order. Also, whether the preference for playing the tracks is equal or favorite tracks are preferred. And, whether a “play count� field in the Track class can help with playing favorite tracks.
Solution:
The method PlayMultipleRandomTracks() can be created which will play multiple random tracks.
The object of class Random can be created inside the PlayMultipleRandomTracks () method.
The nextInt() method can be called on the Random class object to get the random number.
The method playTrack() can be called inside the PlayMultipleRandomTracks() method multiple time to play multiple tracks at random.
The method getNumberOfTracks() can be called inside the PlayMultipleRandomTracks () method as the parameter of nextInt() method to specify the range for generating the random number...
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
- The goal of Snake is to create a snake as long as possible. This is achieved by guiding the snake to an apple on the game board. The snake cannot stop moving, and dies whenever it hits something (excluding apples). Because the snake is growing longer and longer as the game progresses, it gets increasingly difficult to avoid collisions with the snake itself. The player can change the direction of the head of the snake by using the arrow keys. At step in the game, there is always an apple somewhere on the board. If the snake eats an apple, the snake becomes one cell longer. A new apple is placed on a random location, excluding all places covered by the snake. When the snake reaches a side of the game board, it re-emerges at the opposite end.arrow_forwardMy code won't print out the desired test cases. For instance, the time and the event did not properly store it in the skiplistmap class, so it prints out none regardless of time and event. Also, when printing out the skiplist, it will just print out empty for each level regardless of the time and event being stored. So, can you take a look at my code and fix it? Also, how do I use a FakeRandheight class for put(k, v)? mport java.io.File;import java.io.FileNotFoundException;import java.util.Scanner;public class HW5 {public static void main(String[] args) throws FileNotFoundException {SkipListMap<Integer, String> slm = new SkipListMap<>();SkipListMap<Integer, String> cancelEvents = new SkipListMap<>();File input = new File(args[0]);Scanner in = new Scanner(input);while (in.hasNextLine()) {String line = in.nextLine();String[] parts = line.split(" ");if (parts.length == 0) {continue;}String check = parts[0];if (check.equals("AddEvent")) {if (parts.length < 3)…arrow_forwardMake the changes we have described to the Room and Game classes.arrow_forward
- Use the debugger to examine the clock-display project. Set breakpoints in the ClockDisplay constructor and each of the methods, and then singlestep through them. How do you feel about the way it's behaving? Have you gained any fresh insights as a result of this? If this is the case, what exactly were they?arrow_forwardWhat is a HashMap? What is its purpose and how do you use it? Answer these questions in writing, and use the Java library documentation of Map and HashMap for your responses. Note that you will find it hard to understand everything, as the documentation for these classes is not very good. We will discuss the details later in this chapter, but see what you can find out on your own before reading on.arrow_forwardBecause of its GUI programming component, we choose the event delegation design. Do you have any examples to substantiate the statements you're making?arrow_forward
- Added more code to the spin option, but still having issues. Keeps going to Error "Enter an Amonut"arrow_forwardSince creating and destroying a game object are both computationally expensive operations, we can create an object pool, which is a collection of pre-instantiated game objects. What would happen if we had too few or too many game objects in the pool? (Note: what exactly happens may depend on how the object pool is coded)arrow_forwardIt implies testing in a "BLACK Box." What different variants exist on this theme?arrow_forward
- Using java card Graphic GUI, create a card game with a card layout in which 13 cards are displayed and if that card has the king of heart, then lose if not the player winsarrow_forwardCan someone solve the following problem in the 1st screenshot? For extra help, the rules and hints are provided in the 2nd screenshot with different numbers but same idea (PLEASE HELP)!!!arrow_forwardWhy doesn’t this work? And how does the marcher class work? Thanks!arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education