Card Games
[Previous]  [Next] 
|
User Manual [Previous]  [Next] Card GamesThis system will allow players to play card games such as Whist and Oh Hell online. The system should manage the cards in a deck of cards, the players (including who is dealer), the hands of cards each player has, the tricks, the pile of cards on the table. It should also manage the matches between players. Use some background research to improve these simple requirements. Example// Umple class diagram representing card games // in the Oh Hell and Whist family class Card { suit; // "hearts", "clubs", "diamonds", "spades" rank; // A23456789JQK Boolean isJoker; // suit and rank are null for a Joker } class CardSet { // Could be a complete deck or a trick 1 -- * Card; } class NotDealtCardSet { // This would be initialized with a complete 52-card set // at the start of each game // During dealing, the cards would be distributed to players isA CardSet; } class Trick { // A group of cards with one contributed by each player, and // eventually won by a player // One is built after each player has played a card isA CardSet; } class Player { // These are the people playing. name; // A hand is dealt at the start of a game // The cards a player has in his or her hand 0..1 -- * Card hand; // The tricks won by a player this game 1 -- * Trick; // All hands and tricks are cleared at the end of each game // ready for dealing again // The following is used only in Oh Hell Integer currentTricksBid; } class ScoringTeam { // for Oh Hell, it is each player for himself, so there is one player // for Whist there are partners, so there are two players 1 -- 1..2 Player; // The score that each team has accumulated so far // based on tricks taken or difference between tricks and bid Integer score; } class CardsMatch { // A cards match is played in a number of games Boolean isWhist; // True if whist; false if Oh Hell // The following determines the players // the first player in the first team deals first * -- 2..* ScoringTeam; // Exactly 2 if Whist Integer scoreToWin; // The score agreed to in order to declare winner 1 -- * Game games; // Games continue until a player or team wins // Assume that the last game in games is the current one } class Game { trumps; // a suit (if any) that is the trumps for this game // One player is the dealer each game // The dealer deals out all or most of the cards at the start // Players take turn laying down cards to form the next trick * -- 1 Player dealer; // As the cards are laid down the following set is created. // After all players have contributed a new trick is created from the // following and awarded to a player 0..1 -- * Card currentTrickBeingBuilt; * gameLed -- 0..1 Player currentLead; // the player next to lay down a card } Load the above code into UmpleOnline |