Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program that will allow a user to manage the storage portion of a digital music player. Also write a test driver (a

Write a C++ program that will allow a user to manage the storage portion of a digital music player. Also write a test driver (a main() function) that tests the functionality of your music player. The music player will store the following information about each song: Song title (e.g., Hey Jude: may contain spaces, must be unique) Artist name (e.g., The Beatles: may contain spaces, not unique) Size (the songs size in MB; a double with value greater than 0) Play count (the number of times the song has been played; an integer) Lyrics (e.g., Take a sad song and make it better: one line of the songs lyrics, may contain spaces; used in this assignment to simulate playing the song) Your music player should be able to store up to 25 songs and has a maximum storage capacity of 50.0 MB. The music player supports the following operations: 1. Add a new song to the player (prompt the user for input values) 2. Remove a song from the player (prompt the user for title to remove) 3. Play a song (prompt the user for title to play) 4. Display a songs metadata (prompt the user for title) 5. Display the full playlist ordered alphabetically by title 6. Display the players remaining storage capacity (in MB) There should be a separate function associated with each of the above operations. (You may have additional helper functions if you want and in fact, they are strongly encouraged). For the Add Song operation, the program should prompt the user to enter a song title, an artist name, the songs size in MB (with input validation), and a line of lyrics. A complete solution will ensure that the music player is not full (25 songs, or no storage capacity remaining for the songs size). If the song cannot be added, the program should output a message stating why. For the Remove Song operation, the program should prompt the user to enter a song title to remove. The program should indicate whether the operation was successful or not. For the Play Song operation, the program should prompt the user to enter a song title to play. The program should increment the play count of the song, then output the songs name and artist followed by its lyrics. If the song is not found, the program should indicate an error. (You dont need to validate that the play count doesnt overflow the max value of an integer). For the Display Metadata operation, the program should prompt the user to enter a song title to display. It should then output the title, the artist name, the file size, and the play count of the song. If the song is not found, the program should display an appropriate error message. For the Display Playlist operation, the program should display the title, artist, size, and play count for each song, with each song printed on its own line. If the music player is empty, the program should display a message stating so. For the Display Remaining Capacity operation, the program should display the number of MB of remaining storage space available on the music player. All output is to standard (console) out. Your main() function should declare the variables to store the songs and track the song count and capacity. It should then call a sequence of the functions described above in order to exactly match the expected output provided in pr2_expected_out.txt (on the Assignments tab of the course website). You can call the functions anything youd like and set up the parameters and return values however you need. As an example, heres a small segment of my main() function, with the arguments removed: addSong(/* args */); addSong(/* args */); addSong(/* args */); addSong(/* args */); addSong(/* args */); displayEmptySpace(/* args *); addSong(/* args */); displayPlaylist(/* args */); ASSIGNMENT SPECIFICS This assignment is to be completed individually and all submitted code must be your own individual work. Remember that I will grade your program on athena and your grade will reflect only how it compiles/runs on that machine. Additional requirements: Do not use global variables! Global named constants are encouraged. Use an array of Song structures to represent the music player contents. The structure definition should be global, but the array of structures may NOT be global. When the music player contains fewer than 25 songs, all empty slots should be at the back of the array. Keep a count of how many songs are stored in the music player. The songs should always be stored in elements 0 through count-1 of the array. You MUST use binary search for all searches! Your code may not have a linear search anywhere! A good solution may end up needing sort code as well. You may use any of the sorts covered in class. Your program must be modular, with significant work done by functions. Each function should perform a single, well-defined task. You must have a function for each of the 6 music player operations described above. Additionally, you should use functions to avoid code duplication (e.g., dont write the same binary search code twice call a function!). Pay attention to which function parameters need to be references. Because the song title and artist names may include spaces, you will need to use getline() for some input. Remember that using cin >> in combination with getline() can cause problems because cin >> leaves whitespace (including newlines) in the buffer, messing up the next getline() call. You can throw away this whitespace with: cin >> ws;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago