Question
Please and thank you in advance. Also, please give an explanation! We want to implement a Wallet abstract data type that contains a collection of
Please and thank you in advance. Also, please give an explanation!
We want to implement a Wallet abstract data type that contains a collection of Note objects, similar to how a bag contains a collection of generic-type objects. In order to do this, we first must create a Note class.
The Note class should contain a string that contains the name of the piece of money. We will assume that US currency is being used here, so a few examples are as follows: Quarter, 20 Dollar Bill, 5 Dollar Bill, etc.
The Note class should also contain a floating point value that keeps track of the value of the particular Note object in dollars. For example, if the Note was a Quarter then the floating point value would be 0.25f. If the Note object was a 20 Dollar Bill then the floating point value would be 20.0f. The Note class itself does not have to check to ensure that the name string matches the floating point value, it only needs to store these two pieces of information. The Note class should also contain getters and setters for both of these variables. (30 Points)
With the Note class in place, the Wallet can be created. The Wallet ADT should be able to perform the following options:
Add a specific Note object to the Wallet
Remove a random Note and return it
Identify if a specific note is present, and if it is, remove it
Report if the Wallet is empty Report if a specific Note object is inside of the Wallet
Calculate the total amount of money within the Wallet in dollars
Write a Wallet interface that implements the signatures for the methods necessary to perform the above tasks. Next, create a Wallet class that implements this interface and creates the data structure. Note that for simplicitys sake, you may assume that a Wallet will have a maximum capacity of 100 Note objects. (40 Points)
Finally, you should create a main class and method to test out the Wallet and Note classes. The main method should create a Wallet object then read in a floating point number from the user and use this to create a new Note object. The Note objects string name should be determined based on the value of the input value. Below is a list of all of the values your program must recognize. The new Note object should then be added to the Wallet. This should take place inside of a loop and the loop should exit once 100 Note objects have been created, or when the user inputs a value less than or equal to 0. Finally, the main method should print out the total value of Notes inside of the Wallet object before exiting. (30 points)
0.01f= Penny
0.05f= Nickel
0.10f =Dime
0.25f =Quarter
1.00f= 1 Dollar Bill
5.00f= 5 Dollar Bill
10.00f= 10 Dollar Bill
20.00f= 20 Dollar Bill
50.00f= 50 Dollar Bill
Any other value= Undetermined Denomination
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started