Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can anyone did this for me please and explain the code. I know it a lot but please help me. This will be written in

Can anyone did this for me please and explain the code. I know it a lot but please help me. This will be written in the java language.

Coin Class

image text in transcribed

Coin Purse

image text in transcribed

My Purse

image text in transcribed

1. Look over the Coin class to see what it is doing. (has constructor for a coin with two parts: name and value)

2. Look at CoinPurse (think of this class as a big jar filled with coins) This class contains methods to allow us to do things with and to our coins. You need to write these methods.

3. Look at MyPurse. This is the tester class. Here you need to create at least 7 coins, add the 7 coins to the ArrayList then create three lines of output:

a. the total # of coins

b. the total value of these coins

c. what each coin is (a list of 7 names, ex. nickel, penny, penny, quarter, nickel.......)

*The coin class represents a coin obiect which will be stored in a Coin Purse. public class coin // instance var.ables private final in value; privale final storing vName; Constructor for objects of clasa Coin public coin tint valy if (val -- 11 value - val; vName - "PENNY": 1 else if (va. -- 5) 1 value - val; vName = "NICKEL"; 1 else if (val == 10) { value = val; Name - "DIME" 1 else if (val -- 25) value - val; Name - "QUARTER" ; ) else if (va. -- 50) value - vali vName - "EALF DOLLAR"; else if (va. -- 100) 1 value - vali vName = "DOLLAR"; else 1 value - 0 Name - null; 1 + returns the value of this Coin public int gelValue() return this.value; public String toString() return VN : public vod add oia Coin o! import java.util.ArrayList; HA a Cainurse holds a collection of Cain objet. public clasa CoinBuree ArrayList MyPurse.java (378B) Coin Test - Student.zip public class MyPurse { public static void main(String[] args) { CoinPurse mine = new Coin Purse(); //Instantiate some coin objects and add them to CoinPurse mine //Count the total number of Coins in the CoinPurse //Total the Coin in the Coin Purse //Print the Coin Purse }

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_2

Step: 3

blur-text-image_3

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

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

2. What recommendations will you make to the city council?

Answered: 1 week ago