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_forwardHow to Use/Re-Use a Variable Explain how many variables to set up in order to solve a problem in the lab class. Use an example to explain how the variables are changed.arrow_forwardPlease read requirement carefully. DO NOT COPY AND PASTE FROM OTHER SOLUTION AVAILABLE ONLINE There are two players adding words to a growing word fragment. Each player will take turns attempting to add letters to a growing word fragment. The letter you select should attempt to force your opponent to spell a word or create a word fragment that has no possibility of creating a word. Unlike the prior ghost competition, when it is your turn you are allowed to add a letter to either the front or back of the word fragment.Winning Criteria:If your opponent spells a word that is at least 6 characters longif your opponent creates a word fragment that has no possibility of creating a wordif your opponent takes longer than 60 seconds to select a word.Tip: If you are the first player you can only spell words that are odd length thus you can only lose when you spell words that are odd but you can win when your opponent spells words that are even length. Accordingly, if you are the first player you…arrow_forward
- Implement the "Add player" menu option. Prompt the user for a new player's jersey number and rating. Append the values to the two vectors. Ex: Enter a new player's jersey number: 49 Enter the player's rating: 8arrow_forwardSuper Ghost Project Rule changes: The premise of the game remains the same, there are two players adding words to a growing word fragment. Each player will take turns attempting to add letters to a growing word fragment. The letter you select should attempt to force your opponent to spell a word or create a word fragment that has no possibility of creating a word. Unlike the prior ghost competition, when it is your turn you are allowed to add a letter to either the front or back of the word fragment. Winning Criteria: If your opponent spells a word that is at least 6 characters long if your opponent creates a word fragment that has no possibility of creating a word if your opponent takes longer than 60 seconds to select a word. Tip: If you are the first player you can only spell words that are odd length thus you can only lose when you spell words that are odd but you can win when your opponent spells words that are even length. Accordingly, if you are the first player you should…arrow_forwardSimulation parameters: • Define a step size h. Try something small like 0.001 seconds. • Define a length for the simulation-perhaps 10 seconds for now, but feel free to adjust it as you see fit. • Create a list of times that begins at 0 and goes up to the simulation length in steps of h. The actual simulation only cares about the step size, so we won't use this in the simulation but we'll use it for plotting at the end. • Calculate the length of the list created in the previous step and assign it to a variable n. Data arrays: • Create a list r of length n that is all zeros (np.zeros could come in handy here). • Create a list s of length n that is all zeros. Initial conditions: • Set the first entry of r to be some initial height of your choosing. • Set the first entry of s to be some initial velocity of your choosing. First-order equations: • We need to define a function that calculates the derivative of r. Since Eq. 2.14 says that r' s, this is fairlv simply. We iust have to return c…arrow_forward
- Assignment Create a video showing how your game runs, play the game and explain how it plays. (don't worry about code in video).arrow_forwardSuper Ghost Project (Please Help me I don't really know and have no idea ) (CODE PLEASE ) Rule changes: The premise of the game remains the same, there are two players adding words to a growing word fragment. Each player will take turns attempting to add letters to a growing word fragment. The letter you select should attempt to force your opponent to spell a word or create a word fragment that has no possibility of creating a word. Unlike the prior ghost competition, when it is your turn you are allowed to add a letter to either the front or back of the word fragment. Winning Criteria: If your opponent spells a word that is at least 6 characters long if your opponent creates a word fragment that has no possibility of creating a word if your opponent takes longer than 60 seconds to select a word. Tip: If you are the first player you can only spell words that are odd length thus you can only lose when you spell words that are odd but you can win when your opponent spells words that are…arrow_forwardHelp, I making a elevator simulator. Can someone please help me improve this code I have. The remaining code is in the pictures. Any help is appreciated. Thank You! The simulation should have 4 types of Passengers: Standard: This is the most common type of passenger and has a request percentage of 70%. Standard passengers have no special requirements. VIP: This type of passenger has a request percentage of 10%. VIP passengers are given priority and are more likely to be picked up by express elevators. Freight: This type of passenger has a request percentage of 15%. Freight passengers have large items that need to be transported and are more likely to be picked up by freight elevators. Glass: This type of passenger has a request percentage of 5%. Glass passengers have fragile items that need to be transported and are more likely to be picked up by glass elevators. The simulation should also have 4 types of Elevators: StandardElevator: This is the most common type of elevator…arrow_forward
- AVA code OVERVI EW This is a review exercise, so the primary goal of the exercise is to get your mind working and in the correct space.In this activity you will create a imaginary grid of locations that goes from −?≤?≤?, −?≤?≤?, with the coordinate (0,0) being "home". On this grid you will keep track of various animal objects as they move around the grid. Make sure that all animals stay within that grid at all timesincluding when they are created. Zwill be the map size and will control the highest number allowed on themap before wraping around. Using Java, create the following classes and primary program that uses the classes that you developed. INS T RUCT IONS Create the following classes. A N I MA L C LA SS Create an Animal class. Each animal has a name, an x and y integer coordinate. The Animal class should have at minimum the following methodsbelowbut you may want to add more if necessary: Also note, everyanimal will need to have to have “z”passed to it so that it knows how big the…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_forwardPlease help me create a cave class for a Hunt the Wumpus game. You can read the rules in it's entirety of the Hunt the Wumpus game online to get a better idea of the specifications. It's an actual game. INFORMATION: The object of this game is to find and kill the Wumpus within a minimum number of moves, before you get exhausted or run out of arrows. There is only one way to win: you must discover which room the Wumpus is hiding in and kill it by shooting an arrow into that room from an adjacent room. The Cave The Wumpus lives in a cave of 30 rooms. The rooms are hexagonal. Each room has up to 3 tunnels, allowing access to 1, 2 or 3 (out of 6) adjacent rooms. The attached diagram shows the layout of rooms in the cave. The map wraps around such that rooms on the edges (white cells) have neighbors from the opposite edge (blue cells). E.g., the neighbors of room 1 are rooms 25, 26, 2, 7, 6, and 30, and you could choose to connect room 1 to any of these rooms. Observe how room 1…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