X
Xarky
Hi,
I am trying to implement the following program, using OOP concepts,
but I am a bit confused.
The program is to accept audio files of type mp3(version 1 and 2) and
wma. I need to store the artist of the song. This is implemented in
the audio class as public. In class Audio, I have a method which
checks the type and returns an int according to type.
I implemented two other classes(WMA and MP3) which inherit Audio.
Then implemented another two classes (V1 and V2) and inherit MP3.
The artist is to be identified in the classes V1, V2 and WMA.
A sample code is the following:
Class Audio
{
public string artist;
private string path;
public Audio(string filePath)
{
this.path = filePath;
}
public virtual int checkType()
{
if (wma) // not correct syntax
return 1;
else
return 0;
}
public string getArtist()
{
return artist;
}
} // end class
class MP3 : Audio
{
private Audio myAudio;
public MP3(Audio x)
{
this.Audio = x;
}
public override int checkType()
{
// checking from file what type is and returning data
}
}
class V1 : MP3 // V2 and WMA similar
{
private MP3 myMP3;
public MP3(MP3 x)
{
this.myMP3 = x;
}
public void setArtist()
{
// is to be set here by reading from file
// stored in the artist object found in class Audio
}
}
Now I was trying to acess as following, but not working
Audio audio = new Audio(filePath);
int x = audio.getType(); // assume returned for MP3
MP3 mp3 = new MP3(audio);
int x = MP3.getType(); // assume returned for V1
V1 v1 = new V1(mp3);
v1.setArtist();
Now I was trying to get the artist by
audio.getArist();
but surely it wont work.
Is there another way of how to implement it other than getting the
artist from v1.getArtist();
I hope someone understands my problem
Thanks in Advance
I am trying to implement the following program, using OOP concepts,
but I am a bit confused.
The program is to accept audio files of type mp3(version 1 and 2) and
wma. I need to store the artist of the song. This is implemented in
the audio class as public. In class Audio, I have a method which
checks the type and returns an int according to type.
I implemented two other classes(WMA and MP3) which inherit Audio.
Then implemented another two classes (V1 and V2) and inherit MP3.
The artist is to be identified in the classes V1, V2 and WMA.
A sample code is the following:
Class Audio
{
public string artist;
private string path;
public Audio(string filePath)
{
this.path = filePath;
}
public virtual int checkType()
{
if (wma) // not correct syntax
return 1;
else
return 0;
}
public string getArtist()
{
return artist;
}
} // end class
class MP3 : Audio
{
private Audio myAudio;
public MP3(Audio x)
{
this.Audio = x;
}
public override int checkType()
{
// checking from file what type is and returning data
}
}
class V1 : MP3 // V2 and WMA similar
{
private MP3 myMP3;
public MP3(MP3 x)
{
this.myMP3 = x;
}
public void setArtist()
{
// is to be set here by reading from file
// stored in the artist object found in class Audio
}
}
Now I was trying to acess as following, but not working
Audio audio = new Audio(filePath);
int x = audio.getType(); // assume returned for MP3
MP3 mp3 = new MP3(audio);
int x = MP3.getType(); // assume returned for V1
V1 v1 = new V1(mp3);
v1.setArtist();
Now I was trying to get the artist by
audio.getArist();
but surely it wont work.
Is there another way of how to implement it other than getting the
artist from v1.getArtist();
I hope someone understands my problem
Thanks in Advance