please help me with this assignment, will rate lifesaver. please pay attention t
ID: 3623853 • Letter: P
Question
please help me with this assignment, will rate lifesaver. please pay attention to correct spacing and tabs when writing the code, thanks a bunch! :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 iTune 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 iTune 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 iTune streams at or plays at -- higher for better quality, lower for smaller data file size)
Total Time (the playing time of the iTune, represented in milliseconds, i.e., 36500 would stand for 36.5 seconds).
Create a class called iTunes that represents these four items, and provides solid protection for the fields. Then, provide a sample client that instantiates between three and six iTunes objects and mutates and displays these objects. The details follow.
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 total_time - 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 constants:
MIN_BITRATE = 64
MAX_BITRATE = 705
MIN_STR_LENGTH = 1
MAX_STR_LENGTH = 80
MIN_PLAY_TIME = 1000
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 iTune. 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 iTune might be:
"Janiva Magness, You Were Never Mine, 276 seconds, 128 bits per second"
"Title: You Were Never Mine / Artist: Janiva Magness / Playing Time: 4 minutes 36 seconds / Bit Rate: 128k"
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 client has been described, but to summarize, it should instantiate, mutate, display objects and thoroughly test your class. It does not have to take any input from the user. It must certainly confirm, for instance, that your mutators correctly filter out and report bad arguments to the client through its return value
Explanation / Answer
please rate- thanks
the main shows some tings, possibll not all
#include <iostream>
#include <string.h>
using namespace std;
class itunes
{private:
string name;
string artist;
int bitrate;
int total_time;
public:
itunes();
itunes(string,string,int,int);
static const int MIN_BITRATE=64;
static const int MAX_BITRATE = 705;
static const int MIN_STR_LENGTH = 1;
static const int MAX_STR_LENGTH = 80;
static const int MIN_PLAY_TIME = 1000;
static const int MAX_PLAY_TIME = 1000*60*60;
static const int DEFAULT_BITRATE = 64;
static const int DEFAULT_PLAY_TIME = 1000;
static const string DEFAULT_STRING;
void Display();
string getname();
string getartist();
int getbitrate();
int gettotal_time();
void setbitrate(int);
void settotal_time(int);
void setname(string );
void setartist(string );
};
const string itunes::DEFAULT_STRING = " (undefined) ";
itunes::itunes()
{name=DEFAULT_STRING;
artist=DEFAULT_STRING;
bitrate=DEFAULT_BITRATE;
total_time=DEFAULT_PLAY_TIME;
}
itunes::itunes(string n, string a, int b, int p)
{setname(n);
setartist(a);
setbitrate(b);
settotal_time(p);
}
void itunes::Display()
{cout<<"Title: "<<name<<endl;
cout<<"Artist: "<<artist<<endl;
cout<<"Bit Rate: "<<bitrate<<" kilobits per second ";
cout<<"Playing Time: "<<total_time/100<<" seconds ";
}
string itunes::getname()
{return name;
}
string itunes::getartist()
{return artist;
}
int itunes::getbitrate()
{return bitrate;
}
int itunes::gettotal_time()
{return total_time;
}
void itunes::setbitrate(int b)
{if(b<MIN_BITRATE||b>MAX_BITRATE)
{cout<<"bitrate out of bounds, default used ";
bitrate=DEFAULT_BITRATE;
}
else
bitrate=b;
}
void itunes::settotal_time(int t)
{if(t<MIN_PLAY_TIME||t>MAX_PLAY_TIME)
{cout<<"play time out of bounds, default used ";
bitrate=DEFAULT_PLAY_TIME;
}
else
total_time=t;
}
void itunes::setname(string n)
{if(n.length()<MIN_STR_LENGTH ||n.length()>MAX_STR_LENGTH)
{cout<<"name length out of bounds, default used ";
name=DEFAULT_STRING;
}
else
name=n;
}
void itunes::setartist(string a)
{if(a.length()<MIN_STR_LENGTH ||a.length()>MAX_STR_LENGTH)
{cout<<"artist name length out of bounds, default used ";
artist=DEFAULT_STRING;
}
else
artist=a;
}
int main()
{string s;
int i;
itunes a;
a.Display();
itunes b("Janiva Magness", "You Were Never Mine",128, 276 );
b.Display();
s=b.getname();
a.setname(s);
a.Display();
itunes c("", "Hello",1000, 276 );
c.Display();
system("pause");
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.