Page 1 of 1

PROBLEM SOLVING (60 Marks) Write a complete Java program based on the UML class diagram given in Figure 1. Your program

Posted: Tue Jul 12, 2022 8:21 am
by answerhappygod
Problem Solving 60 Marks Write A Complete Java Program Based On The Uml Class Diagram Given In Figure 1 Your Program 1
Problem Solving 60 Marks Write A Complete Java Program Based On The Uml Class Diagram Given In Figure 1 Your Program 1 (61.3 KiB) Viewed 36 times
Problem Solving 60 Marks Write A Complete Java Program Based On The Uml Class Diagram Given In Figure 1 Your Program 2
Problem Solving 60 Marks Write A Complete Java Program Based On The Uml Class Diagram Given In Figure 1 Your Program 2 (67.36 KiB) Viewed 36 times
Problem Solving 60 Marks Write A Complete Java Program Based On The Uml Class Diagram Given In Figure 1 Your Program 3
Problem Solving 60 Marks Write A Complete Java Program Based On The Uml Class Diagram Given In Figure 1 Your Program 3 (21.48 KiB) Viewed 36 times
PROBLEM SOLVING (60 Marks) Write a complete Java program based on the UML class diagram given in Figure 1. Your program should be able to produce the output shown in Figure 3. << interface >> Taxable Tax Rate = 0.075 + calcTax(): double Vehicle -type: String << abstract >> Product -description: String -price: double + Groceries() +Groceries(String, double) getDescription(): String + getPrice(): double abstract calcPrice(): double + abstract dispinfo(): String 4 Vehicle(String, double, String) Food quantity: double purchase Fruit(String, double, double) 7 Figure 1: UML class diagram Customer -name: String totalPrice: double -productList: Vector <Product> + Customer(String) purchase(Product) void +toString(): String + show(): void + calcProductPurchased(): int ProductApp + static main(String): void +static displayMenu(): void
Implement all the classes with the instance variables (attributes) and methods specified in the diagram. The purpose of each method is as the name implies, and some of them are further explained below. Write the program based on the following tasks: (a) Write a class named Customer. The class provides the following instance/ member variables and methods: (11 Marks) (i) Define all the attributes of the class. Note: You need to use the Vector (dynamic array) to declare productList attribute. (1 mark) (ii) Define the constructor with arguments. Initialize all the attributes of the instance with the passed argument and/or zero value. Then, create the object from class Vector that is defined in Task a(i). (1 mark) (iii) Define the toString method. The method returns the following sentence: "<<< (Customer Name)'s shopping list >>>". (1 mark) (iv) Define the calcProduct Purchased method. The method returns the number of products purchased by a customer. (1 mark)
(v) Define the purchase method. The method is used to add an object from the Product class to the product List array and calculate the total price for all of the products purchased by a customer. The object added to the array represents the product purchased (2 marks) by a customer.