Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a console program that will print details of DVDs available to buy. Make

ID: 3742411 • Letter: D

Question

Design a console program that will print details of DVDs available to buy. Make use of an abstract class DVD with variables that will store the title, yearReleased, running time and price of a DVD Create a constructor that accepts the title, yearReleased and running time through parameters and assign these to the class variables. Create an abstract set method for the price of a DVD; also create get methods for the variables Create a subclass InstructionalDVD that extends the DVD class and implements an iPrintable interface. The interface that must be added is shown below public interface iPrintable String ShowDetails(): The InstructionalDVD subclass has a private variable named category for which a get method must be written. The constructor of the InstructionalDVD class must accept the title, yearReleased, running time and category through parameters. Write the code for the setPrice) and ShowDetails() methods Write a useDVD class and instantiate 2 objects of the InstructionalDVD class. Sample output is shown below and you may use the same values to test your application. Output-UseDVD [run DVD Dezail Tear Released: 2012 Prie: 272 Save your files as DVD java, InstructionalDVD.java, useDVD java and iPrintable. java. The criteria in the marking scheme are assessed using the following scale:

Explanation / Answer

abstract class DVD
{
private String title;
private int yearReleased;
private int runningTime;
public int price; // price is public variable to be used in derived class

public DVD(String title,int yearReleased,int runningTime)// constructor
{
this.title = title;
this.yearReleased = yearReleased;
this.runningTime = runningTime;

}

public abstract void setPrice(int price);// abstract method


// get methods
public String getTitle()
{
return title;

}
public int getYearReleased()
{
return yearReleased;
}

public int getRunningTime()
{
return runningTime;
}

public int getPrice()
{
return price;
}
}

interface iPrintable  
{
String showDetails();
}


class InstructionalDVD extends DVD implements iPrintable
{
private String category;

public InstructionalDVD(String title,int yearReleased,int runningTime,String category)// constructor
{
super(title,yearReleased,runningTime);

this.category = category;

}

public String getCategory()
{
return category;
}

public void setPrice(int price)
{
super.price = price;
}

public String showDetails()
{
String s = "";
s = s+"DVD Details "+" Title : "+getTitle()+" Year Released : "+getYearReleased()+" RunningTime : "+getRunningTime()+" min";
s = s+" Category : "+getCategory()+" Price : R"+getPrice();
return s;
}
}
class useDVD
{
public static void main (String[] args)
{
InstructionalDVD dvd1 = new InstructionalDVD("Android Programming",2013,210,"Programming");
dvd1.setPrice(499);

System.out.println(dvd1.showDetails());


InstructionalDVD dvd2 = new InstructionalDVD("Calculus Explained",2012,97,"Calculus");
dvd2.setPrice(725);

System.out.println(dvd2.showDetails());


  
}
}

Output:

DVD Details
Title : Android Programming
Year Released : 2013
RunningTime : 210 min
Category : Programming
Price : R499
DVD Details
Title : Calculus Explained
Year Released : 2012
RunningTime : 97 min
Category : Calculus
Price : R725

DO ask if any doubt. Please upvote.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote