File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ public Card getCard(int i) {
8888 /**
8989 * Returns the last card.
9090 */
91- public Card last () {
91+ public Card lastCard () {
9292 int i = size () - 1 ;
9393 return cards .get (i );
9494 }
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ public void reshuffle() {
6767 /**
6868 * Returns a card from the draw pile.
6969 */
70- public Card draw () {
70+ public Card drawCard () {
7171 if (drawPile .empty ()) {
7272 reshuffle ();
7373 }
@@ -94,20 +94,14 @@ public void displayState() {
9494 discardPile .display ();
9595 System .out .print ("Draw pile: " );
9696 System .out .println (drawPile .size () + " cards" );
97- }
98-
99- /**
100- * Waits for the user to press enter.
101- */
102- public void waitForUser () {
10397 in .nextLine ();
10498 }
10599
106100 /**
107101 * One player takes a turn.
108102 */
109103 public void takeTurn (Player player ) {
110- Card prev = discardPile .last ();
104+ Card prev = discardPile .lastCard ();
111105 Card next = player .play (this , prev );
112106 discardPile .addCard (next );
113107
@@ -124,7 +118,6 @@ public void playGame() {
124118 // keep playing until there's a winner
125119 while (!isDone ()) {
126120 displayState ();
127- waitForUser ();
128121 takeTurn (player );
129122 player = nextPlayer (player );
130123 }
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ public Card searchForMatch(Card prev) {
5757 */
5858 public Card drawForMatch (Eights eights , Card prev ) {
5959 while (true ) {
60- Card card = eights .draw ();
60+ Card card = eights .drawCard ();
6161 System .out .println (name + " draws " + card );
6262 if (cardMatches (card , prev )) {
6363 return card ;
You can’t perform that action at this time.
0 commit comments