Page 1 of 1

(40 Marks) Based on UML class diagram presented in Figure 1, you are require to complete the java program source code in

Posted: Tue Jul 12, 2022 8:20 am
by answerhappygod
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 1
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 1 (87.22 KiB) Viewed 29 times
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 2
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 2 (57.27 KiB) Viewed 29 times
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 3
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 3 (70.85 KiB) Viewed 29 times
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 4
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 4 (56.46 KiB) Viewed 29 times
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 5
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 5 (43.13 KiB) Viewed 29 times
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 6
40 Marks Based On Uml Class Diagram Presented In Figure 1 You Are Require To Complete The Java Program Source Code In 6 (74.26 KiB) Viewed 29 times
(40 Marks) Based on UML class diagram presented in Figure 1, you are require to complete the java program source code in provided templates. The provided template files as follows, Calculator.java, Coin.java, CoinType.java, CustomerRequest.java, DrinkList.java, DrinkSelling System.java and SystemController.java. DrinkSelling System. java is the program with the Main method to test the functionality of the overall application. PROBLEM SOLVING 0.10 <<enumeration>>>> DrinkList CustomerRequest Use Drink SelingSystem Coin Coin Type 1.4 SystemController Calculator Figure 1: Class diagram As shown in Figure 1 with the respective classes, this program will prompt the user to choose type of drink to buy and enter the numbers of coins to buy. After user enter the coins, the program will produced the updated number of coins. Your program should be able to produce the output shown in Figure 2 or in Figure 3.
WELCOME TO THE XYZ DRINK SELLING Drink available: Price: 150(cents) Price: 180(cents) 1 COKE 2 MILK 3 MILO 4 WATER 5 PEPSI - Price: 200(cents) - Price: 120(cents) - Price: 150(cents) Please select your drink: Please enter coins as follows: pum of 10 cents coins, num of 20 cents coins,num of 50 cents coins,num of 1 Ringgit (100 cents) coins Example: If you would like to enter 2 ten cents coins: 2,0,0,0 Plese enter coins: 2,2,2,3 Your change is :260cents splitted as follows: 1 Ringgit (100 cents) coins: 2 50 cents, coins: 1 20 cents coins: 10 cents coins: 1 Figure 2: Sample Output 1 WELCOME TO THE XYZ DRINK SELLING Drink available: Price: 150(cents) 1 COKE 2 MILK Price: 180(cents) 3 MILO Price: 200(cents) 4 WATER - Price: 120(cents) S PEPSI Price: 150(cents) Please select your drink:- Please enter coins as follows: num of 10 cents coins, num of 20 cents coins, num of 50 cents coins,num of 1 Ringgit (100 cents) coins Example: If you would like to enter 2 ten cents coins: 2,0,0,0 Plese enter coins: 1,2,1,2 Your change is :180cents splitted as follows: 1 Ringgit (100 cents) coins: 1 50 cents coins: 1 20 cents coins: 1 10 cents coins: 1 Figure 3: Sample Output 2 Complete the program based on the following tasks. Note that, the tasks are also stated in the program source code in the given templates. The tasks are labeled as Task I to Task 4. IMPORTANT NOTE: Do not modify existing code in the given templates. Only modify the codes based on the comments/instructions stated in Task I to Task 4.
Task 1: In DrinkList.java; This file contains an enumerated type declaration of DrinkList with a list of coin types and prices. Do the following task, i) Complete the enum declaration using the data stated in Table 1. Drink Type COKE MILK MILO WATER PEPSI EMPTY Table 1: Data to be used in DrinkList enum Selection number 1 2 3 4 5 0 (6 Marks) Price in cents 150 180 200 120 150 0 Note: Constant values of the DrinkList enum is the type of drinks, while the selection. number and price are the fields of each constant value. (12 Marks) Task 2: In CoinType.java, Calculator.java and Coin.java: There is an association relationships among Coin, which is a type of class with CoinType and Calculator classes. Do the following tasks; i) There are errors found in the following statements in Calculator.java. Correct the errors. The method getValue () must be able to functions correctly, to show the association relationship between CoinType and enum Coin //red highlighted texts need modification change.num1Ringgit - remaining Amount / getValue(); remainingAmount remainingAmount & getValue (); change.num50cents Coins remainingAmount / getValue();
remainingAmount = remainingAmount 8 getValue (); change.num20 CentsCoins = remaining Amount / getValue (); remainingAmount = remainingAmount getValue (); change.num10 Cents Coins = remaining Amount / getValue (); remainingAmount = remainingAmount getValue (); ii) There are errors found in the following statements in CoinType.java. Correct the errors. The method getValue () must be able to function correctly, to show the association relationship between CoinType and enum Coin //red highlighted texts need modification total total+this.num10 Cents Coins* getValue (); total = total+this.num20 Cents Coins* getValue (); total total+this.num50 Cents Coins* getValue (); total = total+this.numlRinggit getValue ();
Task 3: (6 Marks) In CointType.java; In this class, 4 integer variables are used to store the numbers of coins entered by the user. The variables as follows; num10Cents Coins, num20CentsCoins, num50 CentsCoins and num1Ringgit to calculate the total value of the money. Do the following task; i) Modify the codes, no integer variables are used to store the numbers of coins. Use a single ArrayList object to calculate the total value of the money. ii) Modify the statements in CoinType () constructor. Add elements in coinsDropp [] using proper ArrayList method.
Task 4: In CoinType.java, Calculator.java and DrinkSellingSystem.java; Modification of the CoinType.java will affect the other classes since there has an aggregation relationship between ✓ CoinType.java and DrinkSelling System.java ✔✓ CoinType.java and Calculator.java. Do the following tasks, i) ii) iii) (16 Marks) CoinType.java In getTotal (): modify the following statements by using proper ArrayList method. //red highlighted texts need modification total total+ this.num10Cents Coins total total+this.num20cents Coins total total+this.num50cents Coins total total+this.numlRinggit* getValue(); getValue (); getValue (); getValue (); Calculator.java In calculateChange (): modify the following statements by using proper ArrayList method //the following statements need modification change.numlRinggit = remainingAmount/getValue(); change.num50cents Coins remainingAmount/ getValue (); change.num20cents Coins remainingAmount/ getValue (); change.num10Cents Coins remainingAmount/ getValue (); DrinkSellingSystem.java In displayChangeMessage (), modify the following statements by using proper ArrayList method // red highlighted texts need modification System.out.println(" 1 Ringgit (100 cents) coins: " change.numiRinggit); System.out.println(" 50 cents coins: " change.num50CentsCoins); System.out.println(" 20 cents coins: "+change.num20CentaCoins); System.out.println(" 10 cents coins: " change.num10CentsCoins);