Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>EDITED WITH A COMPLETE EXAMPLE</strong></p> <p>Your Coin class should look something like this:</p> <pre><code>public class Coin { private CoinName coinName; private int year; public Coin(CoinName coinName, int year) { this.coinName = coinName; this.year = year; } @Override public String toString() { return coinName + " " + year; } } </code></pre> <p>The method you don't know what to put in is in there, I made this class to test the answer I'm posting:</p> <pre><code>public class CoinContainer { private Coin[] coins; public CoinContainer() { coins = new Coin[10]; coins[0] = new Coin(CoinName.PENNY, 2011); coins[1] = new Coin(CoinName.DIME, 1952); coins[2] = new Coin(CoinName.DOLLAR, 1999); coins[3] = new Coin(CoinName.NICKEL, 2004); coins[4] = new Coin(CoinName.DIME, 1952); coins[5] = new Coin(CoinName.DOLLAR, 1945); coins[6] = new Coin(CoinName.PENNY, 2011); coins[7] = new Coin(CoinName.QUARTER, 1961); coins[8] = new Coin(CoinName.NICKEL, 1983); coins[9] = new Coin(CoinName.FIFTY_CENT, 1963); } @Override public String toString() { String myString = ""; for(Coin coin : coins) { myString += coin + "\n"; } return myString; } public static void main(String[] args) { CoinContainer coinContainer = new CoinContainer(); System.out.println(coinContainer); } } </code></pre> <p>Finally, for the sake of having a complete answer, your CoinName Enum probably looks something like this:</p> <pre><code>public enum CoinName { PENNY, DIME, DOLLAR, NICKEL, QUARTER, FIFTY_CENT } </code></pre> <p>I tested it and everything works. Here is the output I'm getting:</p> <pre><code>PENNY 2011 DIME 1952 DOLLAR 1999 NICKEL 2004 DIME 1952 DOLLAR 1945 PENNY 2011 QUARTER 1961 NICKEL 1983 FIFTY_CENT 1963 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload