Class cd player

Hi! Im Working on a project of mines and I cant seem to get this class together.
The class im working on is cd player. It can fast forward, rewind, increase volume, decrease volume, get the current song name, get the current volume then returns the current volume, and also sets the volume to 5 and current song to 2. It also has a string array to store the songs (array of size 15 and can hold up to 15 songs), int to keep track of the volume, and int to keep track of the current song.......Here's what I have so far!

#include <iostream>
#include <string>
using namespace std;

class cd
{
public:
cd player(volume = 5, song = 2 );
string song [15];
int forward;
int rewind;
string getSong();
int getVolume();



private:
string song;
int volume;
};
ANY SUGGESTIONS????
well i think thise mite work.

you will have to overload ur ++operator for rewind and operator++ and fast forward functions,sine rewind will have to recall de last track played or playing den pre increment de de list.thise would work.

include thise in your .h
static listSong[strlen(song)];
static maxVolume=50;
string *song;
int SIZE=15;
/////////////////////////////////////////////////////////////////////////
#include "cd.h"
#include<iostream>
#include <cstdlib>
using namespace std;


cd::cd()
{
currentSong=0;
volume=0;
song=new string[SIZE];
for(int y=0;y<SIZE;y++)
{

song[y]=0;//set de playlist to zero first

}
}

cd::player(int v,string arraySongs,int c)
{
setVolume(v);

if(c<0 && c> SIZE)
{
cout<<"Selected trac not allocated in the list"<<endl;
song[c]=0;
}else
{
currentSong=c;
}
}

.................................................................................................................
void cd::setvolume(int d)
{

if(d<0)
{
volume=0;
}
if(d>maxVolume)
{
volume=maxVolume;
}
}
....................................................................................................................
.......................................................................................................
int cd::getVolume()
{

return volume;

}

................................................................................................
string cd::getcurrentsong()
{
return currentsong;

}



................................................................................................................
//thise functon will copy nd store your playlist in computers memory
cd& cd::operator=(const cd &right)
{

if(this==&right)
return *this;

delete[] song;

array=new double[right.strlen(song)];
for(int x=0;x<right.strlen(song;x++)
{
right.song[x]=song[x];
}
return *this;
}


......................................................................................................................
//you will need thise one to controll the []operator for inserting or to retrieve tracks from songArray

double& cd::operator[](int index)
{
return song[index];
}

..............................................................................................................
//add a track to the list
cd cd::operator+(const cd &right)
{
cd r(right.Size);
for(int x=0;x<right.strlen(song);x++)
{
r.song[x]=right.song[x]+song[x];
}
return r;
}
.........................................................................................................
int cd::cd setCurentSong(int s)
{

if(c> SIZE && c<0)
{
cout<<"Selected trac not allocated in the list"<<endl;
song[c]=0;
}
else
{
for(int l=0;l<SIZE;l++)

{
if(song[i]=song[s])
{
song[i]=s;
}
}


}


}
................................................................................................................
//remove a song from de array
cd cd::operator-(const cd &right)
{

cd r(right.Size);

for(int x=0;x<right.strlrn(song);x++)

{

r.song[x]=song[x]-right.song[x];

}


return r;
}

.........................................................................................................
//fast forward
cd cd::operator++(int x)
{
cd temp = *this;

for(int y=0;y<Size;y++)
{

song[y]++;

}
return temp;

}
......................................................................................................................
//rewind and play de previous track
cd cd::operator++()
{


for(int x=0;x<strlen(song);x++)
{
song[x]++;

}

return *this;
}

...............................................................................................................
void cd::setvolume()
{
if(volume>maxVolume)

volume=maxVolume;
cout<<"volume set to maximum"<<endl;
}

esle

{

volume=v;
}

if(volume<0)
{
cout<<"volume is set to zero"<<endl;
}
esle

{

volume=v;
}


}
................................................................................
cd::~cd()
{
delete[] song;
song=0;

}
Last edited on
Topic archived. No new replies allowed.