Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribedQuestion 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: > Payable + double paymento > Item Usefullnfo #String name #String address - String description -double price 1 ..1 IS Customer -static int NO -int referenceNo -Item it -int 1 - Item 12 -int 92 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. 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 Usefullnfo 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: Name: Heng 1 Address: Ang Mo Kio Reference no: 00001 Item purchased Description: Alcohol Unit price: 4.89 Quantity: 65 Name: Heng 3 Name: Heng 4 Total payment: $ 340.36 (**) Address: Bukit Timah Address: Jalan UOW (**Including GST of 7%) Reference no: 00003 Reference no: 00004 Items purchased Items purchased Name: Heng 2 Description: Alcohol Description: Food Address: Toa Payoh Unit price: 96.31 Unit price: 100.22 Reference no: 00002 Quantity: 86 Quantity: 77 Item purchased Description: Food Description: Clothes Description: Clothes Unit price: 9.15 Unit price: 43.79 Unit price: 47.15 Quantity: 42 Quantity: 91 Quantity: 90 Total payment: $ 411.02 (**) Total payment: $ 13125.84 (**) Total payment: $ 12798.12 (**) (**Including GST of 7%) (**Including GST of 7%) (**Including GST of 7%) Include a try block in main and display the following message in the finally block: All tasks in question one processed 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

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

Recommended Textbook for

Visual Basic6 Database Programming

Authors: John W. Fronckowiak, David J. Helda

1st Edition

ISBN: 0764532545, 978-0764532542

More Books

Students also viewed these Databases questions