Object-Oriented Programming · Stackadapt · Medium
Design a class SongShuffler that simulates random playback with a cooldown restriction. The class is initialized with a list of unique song identifiers songs and a nonnegative integer cooldown. After a song is played via shuffle(), it must not be returned again for the next cooldown calls to shuffle(). The method should otherwise return a random song uniformly among those currently eligible, and if no song is eligible it should raise an exception or return a sentinel value…