Answer to Question #265653 in Java | JSP | JSF for nothando

Question #265653


a) Write a CD class that extends the Item class. CD’s have a String artist field and an int playingTime field. This class should have appropriate constructors, getters and setters and should override the toString method and the depreciate method. CD’s depreciate by 10%. b) Write a DVD class that extends the Item class. The DVD class has a String director (the director of the movie) and an int runningTime (how long the movie is). Remember to provide the appropriate constructors, getters and setters and to override the toString method and the depreciate method. DVD’s depreciate by 15%


1
Expert's answer
2021-11-15T17:30:18-0500


package item;




public class Item {


    
    public static void main(String[] args) {
       
    }
    
}


class CD extends Item{
    private String artist; 
    private int playingTime;
    
    






public CD(){
super();
this.artist="";
this.playingTime=0;


}
public CD(String artist, int playingTime) {
super();
this.artist = artist;
this.playingTime = playingTime;
}




public void setArtist(String artist) {
this.artist = artist;
}


public void setNumberOfTracks(int NumberOfTracks) {
this.playingTime = NumberOfTracks;
}


public String getArtist() {
return artist;
}


public int getNumberOfTracks() {
return playingTime;
}
public String toString(){
        return "The Artist is:   "+artist+"\nThe playing time is:  "+playingTime;
    }




}


class DVD extends Item{
    private String director; 
    private int runningTime;
    DVD(String d, int r){
        director = d;
        runningTime = r;
    }
    public String getDirector() {
return director;
}
    public int getrunningTime() {
return runningTime;
}
    public String toString(){
        return "The director is:   "+director+"\nThe Running time is:  "+runningTime;
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS