main |
WarGame |
Player |
Deck |
Pile |
Card
WarGame
secret information
upon creation
- create a new deck of 20 cards
- tell deck "shuffle"
- create a new pile of cards
- create another new pile of cards
- repeat the following 10 times
- ask deck "getTopCard", tell first pile "addCard(thatCard)"
- ask deck "getTopCard", tell second pile "addCard(thatCard)"
- create a player, telling it which pile of cards belongs to it
- create another player and tell it to use the other pile of cards
playTurn
- create a new pile
- do the following until otherwise specified
- ask first player "playCard"
- ask second player "playCard"
- ask first card "compareTo(secondCard)" and remember answer
- tell pile "addCard(firstCard)" and "addCard(secondCard)"
- if answer > 0, stop and tell first player "winCards(pile)"
- if answer < 0, stop and tell second player "winCards(pile)"
- if answer = 0, ask first player "countCards" and second player "count cards"
- if either answer = 0, stop
checkGameOver[answer is: yes/no]
- ask first player "countCards"
- ask second player "countCards"
- if either answer = 0 then answer "yes", otherwise answer "no"
getWinner[answer is: a player]
- ask first player "countCards"
- ask second player "countCards"
- if both answers = 0, answer "no one"
- if first answer = 0, answer "player 2", otherwise answer "player 1"