Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

describe the main employment rights as stated in the law

Answered: 1 week ago