Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

- You will build OnlineShop program for books. Start your program by creating all interfaces and classes shown in the following UML exactly with the

image text in transcribedimage text in transcribed

- You will build OnlineShop program for books. Start your program by creating all interfaces and classes shown in the following UML exactly with the same access modifier: A. General note: 1. Assign any decimal number to the percentage variable. 2. Implements all classes with overriding the required methods. 3. Define one appropriate class as an abstract class. 4. Define all possible class as a final class. 5. Define an argument-constructor for each class and initialize all possible attributes. 6. Define tostring methods. B. Special note for Ibook class: 1. computeAmount method calculates and returns an amount of the book tax (discount) using the formula: \[ \text { Amount }=\text { original_ } \text { price }{ }^{*} \text { percentage } \] 2. Override getPrice() to calculate and return the new price after removing the discount amount from the original price of the book using the formula: \[ \text { New_price }=\text { original_price }-\text { amount } \] C. Define a new class to include two methods: the main method and a generic method (1) In the main method: 1. Declare and initialize an array of 3 Book elements. 2. Put in the array at least three instances of its subclasses (Ibook and PaperBook). Make sure to use your name as the website values, and your ID number as the prices. Divide your ID number into three equal parts, each part is as a price for one object. 3. Invoke the generic method to print the same running example below. (2) The generic method takes an array of generic type that must implement Product interface to: 1. Print information of all objects in the array using a loop. It, also, prints the discount amount for lbook objects. 2. Print the total price that sums all objects prices (after the discount at the Ibook objects). Running example: Ibook { website=abeer. com, original price =440.0, new price =330.0} (The difference: 110.0 SR.) PaperBook { weight =222.0, original price =302.0} Ibook { website =al sheddi.com, original price =300., new price =225.0} (The difference: 75.0SR. ) In total, you pay: 857.0 SR

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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