Answered step by step
Verified Expert Solution
Link Copied!

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 BELOWimage text in transcribed

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 it

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions

Question

=+5 How does HRM relate to efforts to increase innovation?

Answered: 1 week ago