Given the following example code, please help me answer the following questions with hints
public class Coin
{
private String myColor;
private int mySideOne;
private double mySideTwo;
public Coin(String Color, int SideOne, double SideTwo)
{
myColor= Color;
mySideOne = SideOne;
mySideTwo = SideTwo;
}
//accessors getColor(), getSideOne(), and getSideTwo()
}
public class Total
{
private int myNumCoins;
private Coin[] moneyList;
//constructor
public Total(int myCoins)
{
myNumCoins = numCoins;
moneyList = new Coins[numCoins]
String color;
int mySideOne;
double mySideTwo;
for (int i = 0; i<numCoins; i++)
{
}
}
**
Question:
**
//Returns total amount for Coins
public double totalMoney()
{
double total = 0.0;
/* code to calculate
return total;
}
}
Which represents correct / code to calculate amount */ in the totalMoney method?
A. for (Coin t: moneyList)
total+= moneyList.getSideTwo();
B. for (Coin t: moneyList)
total+=t.getSideTwo();
I think A is right because the "t" in B. doesn't exist in the code. How am I wrong?
tis a local variable just the wayiis in the regular for loop