Hi! So I need help with problem 44, chapter 4 in \'Objects First With Java 5th E
ID: 3602412 • Letter: H
Question
Hi!
So I need help with problem 44, chapter 4 in 'Objects First With Java 5th Edition'.
"Consider how you might play multiple tracks in a random order. Would you want to make sure that all tracks are played equally or prefer favorite tracks? How might a “play count” field in the Track class help with this task? Discuss the various options."
I don't understand the solution given by this website. Can you please simplify it and explain the options and how to discuss them? Because I'm really confused right now...
Thank you!
Explanation / Answer
Solution:
Since you have not posted your Track class, so i can not tell ypu how you can implement.
But I can tell you that track count will help you to choose multiple track with equal probability.
Because tract count is the only way to know how many track we have , means how many track we have as a option to play. Generate a randome number between 1 to current_track_count to choose a track.
So if you have choose a track, then current_track_count has decreased by 1, meand you have to generate a random number between 1 to (track_count-1) to choose next track. Yes , you need to move first choosen track at
end so that it can not fall in range 1 to trac_count -1 (because it might be that firt choosen track can be choosen again)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.