Question
C++: Understand the Application An ITunes entry in music library is a descriptor that summarizes information about the tune that it describes. (It is not
C++: Understand the Application An ITunes entry in music library is a descriptor that summarizes information about the tune that it describes. (It is not the actual tune, which is contained in a large music data file.) For each ITunes entry in your own music library file (which is in XML format, but we won't go there) there are between 20 and 50 fields i.e., members. If you were to look at the file on your system, you would find that the fields have names like Genre, Track ID, Name, Artist, Bit Rate, Sample Rate, Track Type, and so on.
We will consider a simplified ITunes class, that stores these ITunes entry objects, with only the following four members for each object:
Name (the title of the song)
Artist (the performing musician or group)
Bit Rate (the number of kilobits per second that the ITunes object streams at or plays at higher for better quality, lower for smaller data file size)
Total Time (the playing time of the ITunes object, represented in milliseconds, i.e., 36500 would stand for 36.5 seconds).
The assignment is to first create a class called ITunes that represents these four items, and provides solid protection for the fields. Then, the client, main(), will instantiate between four or more ITunes objects (some using default constructors and some using parametertaking constructors), display them immediately, mutate many of their fields, display them again to reflect the changes, and finally reset each object to default values and display them one last time. Also, it should do some explicit accessor and mutator tests. This is described in detail further down.
The Program Spec
Class ITunes Spec
Private class instance members:
string name the title of the song. All legal strings should be between 1 and 80 characters.
string artist the performing musician or group. All legal strings should be between 1 and 80 characters.
int bitrate the number of kilobits per second. A legal value should be between 64 and 705.
int totalTime the playing time in milliseconds. A legal value should be between 1 second and 1 hour (expressed in milliseconds)
As stated in the modules, we never want to see a literal in our methods. So the class should have static members to hold values for the limits described above, as well as default values for any field that is constructed using illegal arguments from the client. These are put in the public static section.
Public class static consts:
MIN_BITRATE = 64
MAX_BITRATE = 705
MIN_STR_LENGTH = 1
MAX_STR_LENGTH = 128
MIN_PLAY_TIME = 5000
MAX_PLAY_TIME = 1000*60*60
DEFAULT_BITRATE = 64
DEFAULT_PLAY_TIME = 1000
DEFAULT_STRING = " (undefined)
" You should supply all of the following public instance methods:
Constructors one that takes no parameters (sets values to default) and one that takes all four parameters.
Accessors (get()s) and Mutators (set()s) for each instance member.
string toString() a method that returns a string which contains all the information of the ITunes object. This string can be in any format as long as it is understandable and clearly formatted. Two of the many possible formats for such a string for one ITunes object might be:
"Janiva Magness, You Were Never Mine, 276 seconds, 128k bits per second"
"Title: You Were Never Mine / Artist: Janiva Magness / Playing Time: 4 minutes 36 seconds / Bit Rate: 128k"
void setDefaults() a method that can be called either by the client or as a helper method by the constructors. This method will reset all private data to their default values.
void display() an output method that sends the string returned by the toString() to the screen. display() can, alternatively, send the data directly to the screen on several lines in a different manner than toString(). It can also call upon toString() but prepend and append extra formatting for the console.
The main() driver
main() should instantiate four or more ITunes objects, some of them using the default constructor, some using the constructor that takes parameters. It should immediately display all object. Next, it should mutate one or more members of every object, after which it should display all objects a second time. Then, it should reset all objects to their default values using the appropriate method and display all objects one last time. It does not have to take any input from the user.
Other Testing
After the main section, confirm that your mutators correctly filter out and report bad arguments to the client by placing a couple mutator calls (not all of them) in if statements which print different messages depending on whether the mutator succeeded or failed. Also, demonstrate at least two different accessor calls to show that they work from main().
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started