In: Computer Science
USE C++
Song struct to store the data for a single song (make it a private member), and you must have an array of Song structures as a member variable.
Player(string name, float size) a constructor
for the class. ’name' is a name for it
'size' is a maximum capacity in Mb.
addSong(string band, string title, string length, float size) a function for adding a new song.
'band' is a name of the band
'title' is a name of the song
'length' is a time length of that song in a '1:23' format (“mm:ss")
'size' is a size of the song in Mb
Return true if the song was added and false if there was not enough space (memory) for it or there was a song with the same band and title already in that device or if the device already has 1000 songs in it.
removeSong(string band, string title) a
function for removing a song 'band' is a name of the band
'title' is a name of the song
Return true if the song was successfully removed and false if it wasn't present on the device.
displaySongInfo(string band, string title) a
function to display a song’s info in the following format:
Band:
Length:
Number of songs:
Total length:
Free space left:
The output must line up in two columns, but the labels may be right
justified.
struct Song
{
private string band;
private string title;
private string length;
private float size;
}
class player
{
string nme;
float siz;
player(string name, float size)
{
nme=name;
siz=size;
}
}
public bool addSong(string band, string title, string length, float size)
{
if(band!=null)
{
if(size>1000)
{
return false;
}
if(title.exists())
{
return false;
}
}
Song s[10];
int song_count=0;
cout<<Ënter song to add";
for(int i=0;1;i { song[i+1]=song[i]; } song_count+=1; for(i=0;i<5;i++) { cin>>s[i].band; cin>>s[i].legth; cin>>s[i].title; cin>>s[i].size; } } public bool removeSong(string band, string title) { Song s[10]; int song_count=0; cout<<Ënter song to delete"; for(int i=0;1;i { song[i-1]=song[i]; return true; } return false; song_count-=1; } } public displaySongInfo(string band, string title) { int song_count =10; Song s[song_count]; for(int i=0;i { cout< cout<<"Band:"< cout<<"Tittle:"< cout<<"Number of
songs::"< cout<<"TSize:"< } int main() { cout<< "add song details"; struct song s1,s2,s3; s1.band = ""xxX""; s1.title ="TiX"; s1.leght="23:2"; s1.size="23"; struct song s[5]; int i; for(i=0;i<5;i++) { cin>>s[i].band; cin>>s[i].legth; cin>>s[i].title; cin>>s[i].size; } char yesorno; addSong(s1.band,s1.title,s1.length,s1.size); cout<<"do you wnt to remove songy/n"; cin>>yesorno; if(yesorno='y') removeSong(s1.band,s1.title); cout<<"do you want to display info(y/n)"; cin>>yesorno; if(yesorno='y') displaySongInfo(s1.band,s1.title); }