Question
Question 1 (15 marks) This question tests your ability to use: Polymorphism, interface, and exception handling. Explore the relationship of the following UML diagram: An
Question 1 (15 marks)
This question tests your ability to use: Polymorphism, interface, and exception handling.
Explore the relationship of the following UML diagram:
An online service provider sells all types of items. Customers usually order just one or two items and request the delivery to certain address. The company computes the total payments (including the GST, for example 7% in Singapore).
For each of the classes designed, you must include the following information:
- Meaningful private or protected instance variables.
- Meaningful constructors related to task, including the copy constructor.
- Accessor and mutator methods.
- Dealing with the exceptions for some of the variables used; for example, values or parameters must be positive.
- Other methods required in the design; most importantly, the toString method. You should look at the proposed sample output to decide the format of returning string objects in the toString methods.
A Payable interface class consists of an abstract payment method that you return the computed payment together with some constants to be used in the design, for example, the GST of goods purchased.
A class UsefulInfo implements the Payable interface that consists of two instance variables, the name, and the address.
A class Item consists of two instance variables, the description of an item purchased, for example LV mask, Black Label etc and the unit price of a purchased item.
A class Customer consists of a name, an address, a reference number of good(s) purchased (generated inside the class), information of one or two items (i1 and i2 quoted in UML diagram) purchased, and the quantities (q1 and q2 quoted in UML diagram) purchased for each of the items. This class needs to compute and to return the payment of purchases.
The Customer class needs to describe two types of customers; a customer purchases only one item and a customer purchases two items, i.e., multiple constructors.
In the main class, you are required to construct at least 4 Customer objects: 2 objects for customers who purchase only one item and 2 objects for customers who purchase two items. You need to process all objects polymorphically by displaying some relevant information.
All information required in the design should be randomly generated. Upon execution of your program, you see the following sample displays:
Include a try block in main and display the following message in the finally block:
Full marks will be given students who process the list polymorphically using Lambda and stream.
Save all classes in a Java program called YourName_Supp_1.java and upload this Java file.
Question 1 (15 marks) This question tests your ability to use: Polymorphism, interface, and exception handling. Explore the relationship of the following UML diagram:Step 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