You are on page 1of 3

Ship Sails - Card Game

This game is easy played with the pace. The aim is to collect 7 cards of a
suit. Dealer distributes seven cards to each player face down. The remaining
cards are placed outside the table. Player decide which suit they have to
collect and can change their choice anytime. Game is played with the giving
a card to player on the left and receiving card from the player to his right.
The first player to have all seven cards of same suit wins the game.
http://www.gamblers007.com/18-amazing-fun-card-games-to-play-withfriends-and-family/
Vad har vi fr klasser/objekt?
Vilka metoder och variabler behvs?
Implementing this card game, I have to following classes, methods and
variable.
Classes/Object:
ShipSailsCardGame
PlayGame

Methods:
dealOutCard
leftPlayer
rightPlayer
checkWinner

Variables:

numberOfCards
numberOfPlayers
sevenCards
playerName
rightPlayerCard
leftPlayerCard

leftPlayerCardTotal
rightPlayerCardTotal
counter
playedCard

Vilka arv finns det?


Ta fram
Pseudo-kod
class ShipSailsCardGame{
numberOfCards ;
numberOfPlayers = 0;
sevenCards;
main (){
enter number of players;
dealOutCards(players);
call PlayGame class;
}
dealOutCards(numberOfPlayers){
for 1 to 52{
give a player card;
numberOfCards plus 1
if numberOfCards = 7
break loop;
}
}
}
class PlayGame{
rightPlayer;
leftPlayer;
rightPlayerCard;
leftPlayerCard;
leftPlayerCardTotal;
rightPlayerCardTotal;
playedCard;
PlayGame(){
leftPlayer decide which card to accept?

leftPlayerCard = rightPlayerCard;
rightPlayerCardTotal decrease by one;
leftPlayerCardTotal increment by one;
playedCard = playedCard +leftPlayerCard;
checkWinner(playedCard);
}
checkWinner(playedCard){
counter;
for 1 to 52{
if playedCard = sameSuit {
counter++;
}
}
if counter = 7{
we have a winner;
}
}

You might also like