O-O design implemented in Java. need to use user-defined class, as an array of such class objects will be required. address the O-O concepts by highlighting where in code you are implementing these concepts; Modularity including low coupling rules, Single Responsibility Rule, Open/Closed Principle, Information hiding, Encapsulation, Pre-conditions and Post-conditions, Constructors, Assessors and Mutators, Helper. design + implement your own data class. As the data stored relates to monetary change, the class should be named Change. The class requires at least 2 instance variables for the name of a person and the coin change amount to be given to that person. the coin denominations are $1, 50 cents, 25 cents, 10 cents, and 5 cents. can use 5 instance variables to represent each coin denominations. All these instance variables should be declared as private. key point is to work on design that there is no need for client class to make any change when Change class needs to upgrade to accommodate different coin denominations for different countries. Your class will need to have at least a default constructor, and a constructor with two parameters: one parameter being a name and the other a coin amount. Your class should also provide appropriate get and set methods for client usage. Other methods (including helper) may be provided as needed. However, make sure they are necessary for good class design; you must provide legitimate justification for their usage in the internal and external documentation. In particular, your class should NOT include Input and Output methods. The only way to get data out of a data class object to the client program is to use an appropriate get method. The data class methods must not write data out. Data should be entered into a data class object via a constructor or an appropriate set method. The client program should read the input data from the user and use Change class to store data entered. need a data structure to store the Change class objects according to the number of persons entered. Thus, you are to utilize an array of Change objects. DO NOT USE ARRAYLISTS! input should consist of: the name of a person, and a coin value (as an integer). program should validate the input coin value to ensure that it is evenly divisible by 5. Names are one-word strings. You should ask the user to enter the required information using a loop with a question after each loop iteration to check if the user wants to end the input of data. It is recommended for the user to input at least 10 such data – this can be conveyed to the user using a message before entering the loop. should provide a method in the client class that hardcodes data into at least 10 Change objects and stores these objects into the array provided by your program. provide a call to this method (commented out) in the main function; this can be uncommented When needed. program should check that no same name should be entered. If the same name has been entered, the program should inform the user that the name has existed in the system. Methods would need to be called to calculate required output corresponding to coin amounts stored in the array of objects. Output change values must consist of: $1, 50 cents, 25 cents, 10 cents and 5 cents coins. The program should aim to give as much of the higher valued coins as possible. If the coin amounts entered are not multiple of 5, you need to use a method to change the amount to the nearest of 5 before storing them in the array of objects. E.g. coin amount 94, should be changed to 95 and store 95 in the array of objects. coin amount is 92, should be changed to 90. Once data input is complet, program should display menu screen as illustrated in picture one. When user enters value 1 at menu prompt, program will ask for a name. E.g. Jane, program will output: Customer: Jane 65 cents Change: 50 cents: 1 10 cents: 1 5 cents: 1 N.B. change values of 0 are not shown for screen output. If user enters a non-existent name at menu option 1, your program will print: Name: Donald NOT FOUND The menu is re-displayed. enters 2 at the menu prompt, program will search all objects in array to find object with largest coin amount. Then output name, and denomination breakdown change. the menu is re-displayed. enters 3 at the menu prompt, program will search all objects in array to find object with the smallest coin amount. program will output name and denomination breakdown. the menu is re-displayed. enters 4 at the menu prompt, program will access all objects in the array to calculate and display total number of coins for each denomination. displays the number of coins and NOT amount of each denomination. the menu is re-displayed. enters 5 at the menu prompt, program will access all objects in array to calculate the sum of the amounts from all denominations. this option displays the amount and NOT the number of coins.The menu is re-displayed.
O-O design implemented in Java. need to use user-defined class, as an array of such class objects will be required.
address the O-O concepts by highlighting where in code you are implementing these concepts; Modularity including low coupling rules, Single Responsibility Rule, Open/Closed Principle, Information hiding, Encapsulation, Pre-conditions and Post-conditions, Constructors, Assessors and Mutators, Helper.
design + implement your own data class. As the data stored relates to monetary change, the class should be named Change. The class requires at least 2 instance variables for the name of a person and the coin change amount to be given to that person. the coin denominations are $1, 50 cents, 25 cents, 10 cents, and 5 cents. can use 5 instance variables to represent each coin denominations. All these instance variables should be declared as private. key point is to work on design that there is no need for client class to make any change when Change class needs to upgrade to accommodate different coin denominations for different countries.
Your class will need to have at least a default constructor, and a constructor with two parameters: one parameter being a name and the other a coin amount. Your class should also provide appropriate get and set methods for client usage. Other methods (including helper) may be provided as needed. However, make sure they are necessary for good class design; you must provide legitimate justification for their usage in the internal and external documentation. In particular, your class should NOT include Input and Output methods. The only way to get data out of a data class object to the client program is to use an appropriate get method. The data class methods must not write data out. Data should be entered into a data class object via a constructor or an appropriate set method.
The client program should read the input data from the user and use Change class to store data entered. need a data structure to store the Change class objects according to the number of persons entered. Thus, you are to utilize an array of Change objects. DO NOT USE ARRAYLISTS!
input should consist of: the name of a person, and a coin value (as an integer). program should validate the input coin value to ensure that it is evenly divisible by 5. Names are one-word strings. You should ask the user to enter the required information using a loop with a question after each loop iteration to check if the user wants to end the input of data. It is recommended for the user to input at least 10 such data – this can be conveyed to the user using a message before entering the loop.
should provide a method in the client class that hardcodes data into at least 10 Change objects and stores these objects into the array provided by your program. provide a call to this method (commented out) in the main function; this can be uncommented When needed.
program should check that no same name should be entered. If the same name has been
entered, the program should inform the user that the name has existed in the system.
Methods would need to be called to calculate required output corresponding to coin amounts stored in the array of objects. Output change values must consist of: $1, 50 cents, 25 cents, 10 cents and 5 cents coins. The program should aim to give as much of the higher valued coins as possible.
If the coin amounts entered are not multiple of 5, you need to use a method to change the amount to the nearest of 5 before storing them in the array of objects. E.g. coin amount 94, should be changed to 95 and store 95 in the array of objects. coin amount is 92, should be changed to 90.
Once data input is complet, program should display menu screen as illustrated in picture one.
When user enters value 1 at menu prompt, program will ask for a name. E.g. Jane, program will output:
Customer:
Jane 65 cents
Change:
50 cents: 1
10 cents: 1
5 cents: 1
N.B. change values of 0 are not shown for screen output.
If user enters a non-existent name at menu option 1, your program will print: Name: Donald NOT FOUND
The menu is re-displayed.
enters 2 at the menu prompt, program will search all objects in array to find object with largest coin amount. Then output name, and denomination breakdown change. the menu is re-displayed.
enters 3 at the menu prompt, program will search all objects in array to find object with the smallest coin amount. program will output name and denomination breakdown. the menu is re-displayed.
enters 4 at the menu prompt, program will access all objects in the array to calculate and display total number of coins for each denomination. displays the number of coins and NOT amount of each denomination. the menu is re-displayed.
enters 5 at the menu prompt, program will access all objects in array to calculate the sum of the amounts from all denominations. this option displays the amount and NOT the number of coins.The menu is re-displayed.
Step by step
Solved in 4 steps with 12 images