Create an implementation for the SongCache interface shown below, being mindful of concurrency. The solution can assume

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Create an implementation for the SongCache interface shown below, being mindful of concurrency. The solution can assume

Post by answerhappygod »

Create An Implementation For The Songcache Interface Shown Below Being Mindful Of Concurrency The Solution Can Assume 1
Create An Implementation For The Songcache Interface Shown Below Being Mindful Of Concurrency The Solution Can Assume 1 (153.42 KiB) Viewed 19 times
Create An Implementation For The Songcache Interface Shown Below Being Mindful Of Concurrency The Solution Can Assume 2
Create An Implementation For The Songcache Interface Shown Below Being Mindful Of Concurrency The Solution Can Assume 2 (46.22 KiB) Viewed 19 times
Create an implementation for the SongCache interface shown below, being mindful of concurrency. The solution can assume that JDK 11 will be used to build. We are looking for both correctness and good coding style. Please make sure that your code is well-designed and architected, in addition to being algorithmically efficient. . Include a simple document explaining your solution. See this unit test for guidance. @Test public void cacheIsWorking() { SongCache cache = new Song CacheImpl(); cache. recordSongPlays ("ID-1", 3); cache. recordSongPlays ("ID-1", 1); cache. recordSongPlays ("ID-2", 2); cache. recordSongplays ("ID-3", 5); assertThat(cache.getPlaysForSong ("ID-1"), is(4)); assertThat (cache.getPlaysForSong("ID-9"), is(-1)); assertThat(cache.getTopNSongsPlayed (2), contains("ID-3", "ID-1")); assertThat(cache.getTopNSongsPlayed(0), is (empty())); } interface SongCache { /** * Record number of plays for a song. */ void recordSongPlays (String songId, int numPlays); /** * Fetch the number of plays for a song. *
* @return the number of plays, or -1 if the song ID is unknown. */ int getPlaysForSong (String songId); /** * Return the top N songs played, in descending order of number of plays. */ List<String> getTopNSongsPlayed (int n); }
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply