Question
1. Write two Java classes ( Television and Laptop) to meet the requirements described in the UML Class Diagram attached to the assignment. 2. Write
1. Write two Java classes (Television and Laptop) to meet the requirements described in the UML Class Diagram attached to the assignment.
2. Write an interface program/class (Discount) and use it to process the set of two concrete classes (Television and Laptop) polymorphically.
3. In each of the two classes (Television and Laptop), implement the interface program (Discount) and invoke getSalesDiscount method with the following condition statements:
If TV price is less than $400 then get the Tv price and multiply by 10%.
Else multiply by 15%
And
If Laptop price is less than $650 then get the Laptop price and multiply by 10%.
Else multiply by 15%
NOTE: The only direct access to instance variable values is through the set and get methods; no other direct access is ever permitted.
Expected toString Output
Your output need not be identical to that shown here, but you MUST include all instance values in the output, in the order shown.
LABOR-DAY SALES!!!!
Television Brand: Sharp
Model Number: KEN564GUI
SKU Number: 1722-4
Screen Size: 50 inch
Price before Labor-day: 628.34
Discounted price: 534.09
Labor-Day sales discount: 94.25
LABOR-DAY SALES!!!!
Laptop Brand: HP
Model Number: USA2783UL
SKU Number: 323-UI
Screen Size: 15 inch
Price before Labor-day: 763.49
Discounted price: 648.97
Labor-Day sales discount: 114.52
public class DiscountInterfaceTest { public static void main(String[] args) { // 6 elements of Discount array Discount[] discountObjs = new Discount[] { new Television("Samsung", "UKD123FIO", "6252-1", "50 inch", 560.24), new Television("LG", "NIG324DIO", "9282-5", "50 inch", 387.46), new Television("Sharp", "KEN564GUI", "1722-4", "50 inch", 628.34), new Laptop("HP", "USA2783UL", "323-UI", "15 inch", 763.49), new Laptop("Dell", "HOU3463HYO", "374-GF", "15 inch", 1536.87), new Laptop("Acer", "AUS9193GH", "123-AI", "15 inch", 610.10), }; System.out.println("-----------------------------------------------"); for (Discount laborSales : discountObjs) { System.out.printf("%n%s %n%s%n%s: %,.2f%n", "LABOR-DAY SALES!!!!", laborSales.toString(), "Labor-Day sales discount", laborSales.getSalesDiscount()); } System.out.println("-----------------------------------------------");
} }
> Discount public abstract getSalesDiscount:double Retums the aurrent sales Discount values of concrete classes references llaptop Television private final laptopBrand Strin private final modelNumString private final shtunString private final laptopSize: String private final double laptopPrice double Laptop price Laptop brand Model Number Stock-Keeping unit number Laptop screen size private final brand String private final modelNumberString private final skhuNumberString private final trSize String private final double tPrice double Television brand Model Numbe Stock-Keeping unitnumber Television screen size Telerision price Laptop (laptopBrand Strine modelNunString, skuNum String, laptopSizeString laptopPricedouble and fully functional Laptop reference. Constructor accepting five (S) parameters, with Television (Brand String Stringand double types. Retuns a fully formed modelNumber String satunber. String, Constructor accepting five (S) parameters, with Stringand double types. Retums a fully fonmed and fully functional Telerision trSize String tPricedouble Television public-taptopBrand String public getModelNurn String public getskuNuml String public getiaptopSizel Strine public getlaptopPricel: double public salesDiscount double Returns the arret value of instance variable utlic metBrandString Retums the orent yalue of instance variable public getModelNumberl String Retu ms the curentyalue of instance yariable public getSkuunberlString Retums the aurent value of instance variable public retr Sizelk Strine Rethrms the arrent value of instance variable Brand Retuns the ourent value of instance Retu ms the ourent value of instance Retums the arrent value of instance ariable tSiue Retums the crentralue of instance ariable t Price Retu ms the ourent sales discountvalues of concrete class objects. And enforce a conditional statement (herk Retums a formatted String containing the curent ralues of each of the object's instance variables. Create spece holders for the folloing Television Brand", metBrand. "hlodel Retums the cu rent ralue of instance variable public getT Pricel double ptopPrice Returms the curentof sales discount yalues ofpublic getSalesDiscountlE double concrete class objects. And enforce a conditional public toString String Retums a formatted String containig the curment values of each of the objects instance variables. Create spece holders for thefoloing Taptop Brand.geaptopBrandl. Model Humber.relModel.SUunber public toStringlString Price before Labor-dasgaptopPricel Discounted price. raptopPricel ice before Labor-day-.ffwPrice1 Discounted price. retPricelStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started