At first I thought I would need to create an array but since Im calling upon the Deck class I don't think I should need to create an array, right?
There is a one to one mapping between the methods that you need to write
But then I realised that the assignement instructions say that we are not allowed to modify the Deck class.
How do I implement the top method so that it does not remove the top card but instead just return a reference to it?
How does it fail?
I am having a bit of trouble with the toString() method. It compiles but isnt passing the unit test.
Unfortunately the cards List of Deck is not accessible and you can't change the Deck class, so using the get(int) method seems to be ruled out. What I suggested before was:
(1) card from the Deck - use nextCard()
(2) put it back - use addAtStart()
(3) return the card to the caller - use return
you are returning too soon. (The compiler would have told you this). Think about introducing a new variable:
public Card top()
if(deck.numCardsRemaining() == 0)