Question: Java NetBeans Modify the PolymorphicInterface app to add a 3rd and a 4th class which implement RetailItem, named VideoGame and MP3Download. Include appropriate properties and

Java NetBeans

Modify the PolymorphicInterface app to add a 3rd and a 4th class which implement RetailItem, named VideoGame and MP3Download. Include appropriate properties and methods. Also add a percentDiscount attribute to all 4 of these classes. Modify the getRetailPrice method in each to apply the current discount (e.g. return retailPrice*(1-percentDiscount) ). Modify the RetailItem interface to include a 2nd method, named getPercentDiscount( ). Modify main( ) to exercise these new classes, similar to how it exercises the other 2 classes.

public class PolymorphicInterface { public static void main(String[] args) { // Create a CompactDisc object. CompactDisc cd = new CompactDisc("Greatest Hits", "Joe Looney Band", 18.95); // Create a DvdMovie object. DvdMovie movie = new DvdMovie("Wheels of Fury", 137, 12.95);

// Display the CD's title. System.out.println("Item #1: " + cd.getTitle()); // Display the CD's price. showPrice(cd); // Display the DVD's title. System.out.println("Item #2: " + movie.getTitle()); // Display the DVD's price. showPrice(movie); }

/** The showPrice method displays the price of a RetailItem object. @param item A reference to a RetailItem object. */ private static void showPrice(RetailItem item) { System.out.printf("Price: $%,.2f ", item.getRetailPrice()); } }

Here's RetailItem

/** RetailItem interface */

public interface RetailItem { public double getRetailPrice(); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!