Question: The code in the Coin.txt: public class Coin{ private int value; public Coin(){/on-parameter constructor value=25; } public Coin(int value){//parameterized constructor setValue(value); } public int getValue(){

The code in the Coin.txt:
public class Coin{
private int value; public Coin(){/on-parameter constructor value=25; } public Coin(int value){//parameterized constructor setValue(value); }
public int getValue(){ return value; } public void setValue(int value){ if(value == 1 || value==5 || value==10 || value==25) this.value = value; else this.value=1; }
public String getName(){ String name="Penny"; switch(value){ case 5: name="Nickle"; break; case 10: name="Dime"; break; case 25: name="Quarter"; break; } return name; } }
The code in the wallet.txt:
public class Wallet{
private Coin[] coins;
public Wallet(Coin[] coins){ setCoins(coins); }
public Coin[] getCoins(){ return coins; } public void setCoins(Coin[] coins){ this.coins = coins; } public int totalValue(){ int total=0; for(int i=0; i }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
