How would you build a JAVA Code with a class called Wallet using the specifications given in
Fantastic news! We've Found the answer you've been seeking!
Question:
How would you build a JAVA Code with a class calledWallet using the specifications given in the form of a UML class diagram?
The three constructors set the instance variables to the desired values:
- The default no-args constructor should set all the values to zero.
- The constructor taking a Wallet parameter is a copy constructor.
- The third constructor is the full constructor for the class. Its parameters should be listed in the natural order 100, 50, 20, ... If any of its argument is less than zeo, the constructor should change the negative value to zero.
Most of the other methods are self-explanatory, except for
- The getTotalWallet method, which simply return the total dollar value of this wallet.
- The combineWallets, which takes a wallet object as a parameter and returns a new wallet whose instance variables are the sum of the corresponding variables in this (the calling object) and the Wallet object passed as an argument. If the argument is null, the method should return the calling object.
- The toString method must, as usual, be formatted EXACTLY as follows:
Wallet[$100: 0, $50: 1, $20: 2, $10: 3, $5: 4, $1: 5]
with the different bill counts adjusted as appropriate.
- The equals method is the simplified equals method discussed in the reading materials.
Please make sure you respect the class, methods, and attribute names. Failure to do so will result in validation tests failure.
Related Book For
Posted Date: