public class CD
{
// attributes
int tracks;
String name;
/**
* Constructor for objects of class CD
*/
public CD(String n, int x)
{
name = n;
tracks = x;
}
public int getTrack(){
return tracks;
}
}
public class CDplayer {
String status;
int track_num = 1;
CD myCD;
public void load(CD cd1){
myCD = cd1;
}
public void play(){
status = "play";
}
public void forward(){
track_num = track_num + 1;
if(track_num > myCD.getTrack()){
track_num = 1;
}
}
}
Post a Comment
Hi. :-h