Need Help ?

Home / Expert Answers / Other / problem-solving-100-marks-write-a-complete-java-program-based-on-the-uml-class-diagram-given-in-figu

(Answered): PROBLEM SOLVING (100 Marks) Write a complete Java program based on the UML class diagram given in F ...



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

1) The class should have six (6) private member variables (attributes) (refer to Figure 1). Two of the member variables are t

3. : Total sales = RM##.## Please display an appropriate message if there is no order, i.e. No order!. Note: You may need t

(2) Add Menu [9.5 marks] Ask the user to enter the menus type, name and price. If it is a pizza menu, ask the user to enter

(11) Write the codes for displayDetails method that will display the menus name, prece and whitespace in the following forma

PROBLEM SOLVING (100 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 2. <<abstract>> Menu Staff # name: String #price:double - staffld, name: String - numPromo, numiza: int orderList: Menul attyList: Integer addorden) + 0.. 1.. + Menu(String, double) + getName(): String + abstract calc Total(): double + abstract displayDetails(): void + Staff String. String) + getStaffid- String + addOrder(Menu, int): void + displayInfo Staff(): void + displayInfo Order() void Pizza Promo size: String + Pizza(String, double. String) + Promo(String, double) <cinterface >> Disc Considerable Order Test DISC =10: double calcDisc(): double + static main(String I): void + static menu(): void Figure 1: UML class diagram You must write six complete classes, Menu, Staff, Promo, Pizza, DiscConsiderable and OrderTest based on the instruction given below: (a) Write a class named Staff. The class provides the following instance/ member variables and methods: (22.5 Marks) 1) The class should have six (6) private member variables (attributes) (refer to Figure 1). Two of the member variables are the array of Menu objects named orderlist and the array of Integer objects named attyList. Note: You are allowed to use dynamic array ArrayList or Vector) or static array for orderList and qttyList. (2 marks) (11) Write the codes for a constructor with arguments that accepts the staff's id and name. This value should be assigned to the staff's staffId and name member variables. The constructor also enables to assign zero (0) to the numPromo and numPizza member variables, and creates orderList (the array of Menu to hold objects of Menu) and qttyList (the array of integer). (2.5 marks) (111) Write the codes for getStaffId method that returns the value of staffIa member variable. (1 mark) (iv) Write the codes for addorder method that will receive two arguments of Menu instance and an integer value, update the array named orderList and qttylist to include the new instance of Menu and the new integer value in the arrays and update the number of promo and pizza memus. (4.5 marks) (5) Write the codes for displayInfoStaff method to display the staffs id and name of Staff's object in the following format (please refer to the sample output given in Figure 2): (1.5 marks) Staff Id : ????? Staff Name: ????? ????? (vi) Write the codes for displayInfoOrder method to display the number of promo and pizza menus of Menu's object, the number of all menus, the list of menus and total of sales (if any) in the following format (please refer to the sample output given in Figure 2): (10 marks) Number of All Orders : ++ Number of Promo Orders: ++ Number of Pissa Orders: ++ Unit Price (PM) Discount (RM) Quantity No Description Total (BM) 1. ????? ????? ????? ????? .## #.** ++++ 3. : Total sales = RM##.## Please display an appropriate message if there is no order, i.e. "No order!". Note: You may need to invoke an appropriate method(s) defined in this class or other class to display the list of orders. (6) Write an abstract superclass named Menu. The class provides a constructor with arguments that will initialize all the member attributes to the values received as arguments. It also provides getName method that returns the value of name member variable. (5 Marks) © Write a subclass Promo and implements interface with the following codes: (8 Marks) 1) Write the codes for a constructor with arguments that will initialize all the superclass's attributes. (1.5 marks) (1) Write the codes for calcDisc method that will return discounted price. The discount of promo menu is 10% (please refer to the interface). (1.5 marks) (111) Write the codes for calcTotal method that will return the price after discount. (1.5 marks) (iv) Write the codes for displayDetails method that will display the menu's name, price, and discounted price in the following format (please refer to the sample output given in Figure 2): (2 marks) ????? ????? ##.## #. ## (d) Write a subclass Pizza with the following codes: (6 Marks) (1) Write the codes for a constructor with arguments that will initialize all the member attributes for the class, including the superclass's attributes. (2 marks) (11) Write the codes for calcTotal method that will return the menu's price. (1 1- (2) Add Menu [9.5 marks] Ask the user to enter the menu's type, name and price. If it is a pizza menu, ask the user to enter the pizza size and update the name of pizza by including the pizza size. - Create a new menu (a promo or pizza) object. Hint: Use a polymorphic concept. - Insert a new menu object into the Menu array. Note: You are allowed to use dynamic array ArrayList or Vector) or static array for the Menu array. B3] Add Order [15 marks] Ask the user to enter the selected staff. Ask the user to enter the selected menu and quantity required. - Insert a new order object into the Menu array for the selected staff. The process of a new order insertion will be continued until the user enters invalid input - If there is no staff or memu, display an appropriate message, i.e. "Sorry!! No staff or menu, please add staff or menu first...". [4] Display Orders [6.5 marks] - Display the information of all the orders based on staff if any. If there is no staff, display an appropriate message, i.e. "Sorry!! No staff, please add staff first..." [5] Exit [0.5 mark] - End the program by displaying an appropriate message, i.e." Thank you! :)" (8) Using an appropriate structure for the program such as using a proper output formatting, indentation and Java statements. (3 Marks) (h) The program is able to run, work, and display the output as required. (4 Marks) (11) Write the codes for displayDetails method that will display the menu's name, prece and whitespace in the following format (please refer to the sample output given in Figure 2): (1.5 marks) ????? ????? (whitespace) (e) Write an interface named DiscConsiderable with the following codes: (1.5 Marks) 1 Declaration of one final static variable. (11) Declaration of one abstract method. (f) Write a driver class named OrderTest. The class provides the following methods: (49.5 Marks) 1) Write the codes for menu method that will provide the user a menu-driven interaction as follows (please refer to the sample output given in Figure 2): marks) [1] Add Staft (2) Add Menu [3] Add Order [4] Display Orders [5] Exit (11) Write the codes for main method that will produce the output like the sample output given in Figure 2 according to the following descriptions: (47 marks) - Identify the suitable variables and/or instances where appropriate. Create a static or dynamic array of Staff and Menu objects. Create a Scanner object for input purpose. Ask the user to enter the chosen task. Note that all the interactions shown in Figure 2 are continuous in a single run. Note also that, the bold texts indicate input entered by the user. [1] Add Staff [4 marks] Ask the user to enter the staff's id and name. Create a new Staff object. Insert a new staff object into the Staff array. Note: You are allowed to use dynamic array ArrayList or Vector) or static array for the Staff array.


We have an Answer from Expert

View Expert Answer

Expert Answer


Answer to PROBLEM SOLVING (100 Marks) Write a complete Java program based on the UML class diagram given in Figure 1. Your program...
We have an Answer from Expert

Buy This Answer $4

Place Order