Class GameController

java.lang.Object
  extended by GameController

public class GameController
extends java.lang.Object


Constructor Summary
GameController()
          Creates a controller to play the Aces Up game.
 
Method Summary
 void deal()
          Adds a card from the deck to the end of each of the card lists if the deck is not empty.
 void discard(int listNum)
          Moves the last card from the given list to the discard pile if the list is not empty and the last card has a rank that is greater than the last card on another list with the same suit.
 PlayingCard getCard(int listNum, int index)
          Gets the card in the specified list number at the given index.
 int getScore()
          Gets the current score.
 void move(int listNum)
          Move the last card from the given list (if the list is not empty) to an empty list if one exists.
 void startNewGame()
          Moves all cards from the lists and discard pile back into the deck of cards, shuffles the deck and starts a new game.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GameController

public GameController()
Creates a controller to play the Aces Up game. The controller creates a deck of cards as an arraylist, four empty arraylists for the four card lists of the game, and an arraylist for the discard pile.

Method Detail

getCard

public PlayingCard getCard(int listNum,
                           int index)
Gets the card in the specified list number at the given index. If the given list is empty, this method returns null. If the given index is invalid for the given list, this method returns null.

Parameters:
listNum - The number of the desired card list between 0 and 3 inclusive
index - The position of the card desired in the given list between 0 and the size of the list - 1
Returns:
The reference to the desired card, or null if the desired list is empty or the index is invalid

getScore

public int getScore()
Gets the current score.

Returns:
The current score for the game.

deal

public void deal()
Adds a card from the deck to the end of each of the card lists if the deck is not empty. Otherwise, do nothing.


discard

public void discard(int listNum)
Moves the last card from the given list to the discard pile if the list is not empty and the last card has a rank that is greater than the last card on another list with the same suit. Otherwise, do nothing.

Parameters:
listNum - The number of the desired card list between 0 and 3 inclusive

move

public void move(int listNum)
Move the last card from the given list (if the list is not empty) to an empty list if one exists. Otherwise, do nothing.

Parameters:
listNum - The number of the desired card list between 0 and 3 inclusive

startNewGame

public void startNewGame()
Moves all cards from the lists and discard pile back into the deck of cards, shuffles the deck and starts a new game.