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
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.