Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a class called Coin as follows: Attributes: name and value of a coin (valid names and values are Toonie(200), Loonie(100), Quarter(25), Dime(10) and Nickel(5)).
Create a class called Coin as follows: Attributes: name and value of a coin (valid names and values are Toonie(200), Loonie(100), Quarter(25), Dime(10) and Nickel(5)). Methods : Constructor that sets the name and value; Get methods toString method
*I am using JGrasp so please make sure it is compatible
*Please comment throughout code
*FULL QUESTION IN IMAGES BELOW
Exercise 2: Create a class called Coin as follows: Attributes name and value of a coin (valid names and values are Toonie(200), Loonie(100), Quarter(25), Dime(10 and Nickel(5). Methods Constructor that sets the name and value, Get methods toString method Create another class called Wallet that is aggregated from the Coin class as follows: Attributes An array of Coin objects capacity (how many coin objects it can hold an integer value) num (current number of coin objects in the wallet -an integer value) total value of all Coin objects (in cents) stored in the wallet (an integer value) Methods: Constructor (that sets the total value to zero, num to zero, the capacity to the given value, and creates an array of Coin objects of size equal to the capacity) addCoin (that adds a given Coin object to the Coin object array and updates the num and total value) removeCoin (that removes the last Coin object from the array and returns it, it should also update the total value and num toString method Note: addCoin and removeCoin methods should have the appropriate error checks Test the classes by creating a Wallet, and adding and removing coins from itStep 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