Hi to all....Can some one help me out to make this project plz....
Help needed in urgent plz anyone.....
Solitaire-like card games
You may use VC++ 6.0 (no .NET allowed) environment for this project. In that case,
you will need to submit the whole workspace and the project
In this project, you will be implementing three solitaire-like card games. Since these
games are related to each other in a close manner, you will use inheritance during your
implementation. In fact, you will use two separate inheritance relationships in this
project. One is between different piles of cards and the other is between various games.
You can find information on Solitaire games at
http://www.goodsol.com but you are not
required to go to that web site for this project.
Card games follow different rules. There are so many of them that the games with
slightly different rules may sometimes use the same name. You must implement the rules
we define here. Do not come back to us saying that the rules we have specified are
incorrect. If they seem incorrect to you, assume that this is some different planet where a
tomato means a monkey and where monkeys mean grades!
Here is what is common to most Solitaire games, at least the ones we consider in this
project. We are actually providing you the class description that should make your job a
lot easier. Some starter code is also being provided.
The Base Classes
Card:
A Card is one of the 52 units used to play card games. There are 4 suits (Hearts, Clubs,
Spades, and Diamonds) and 13 ranks (A/1, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K) in each suit.
From a programming perspective, this is a class which should hold all the data which can
distinguish a Card from another. It should also provide methods “comparing” itself to
another Card. This comparison is not necessarily the equality or inequality comparison.
Other comparisons should also be possible, for example if two Cards have same suit or
same rank. A Card may also provide a toString() method which simply returns a
C++ string to facilitate printing this Card. A Card should only be printed when it is
facing up. So, perhaps the toString() method should return a string “down” or
something like that if the Card is not up.
1 This project has been derived from a previous programming project which was given to students taking a
programming course offered by computer science department at Stanford University.
Page 2 of 8
To make life simple, you should use ints as the ranks. Use 11 for J, 12 for Q and 13 for
K. Your Card class will also provide a method to return the rank of a specific Card.
Similarly, you might need a method to return the suit of a Card.
Deck:
A Deck is a collection of all 52 cards. The constructor of Deck should initialize the
Deck to hold all 52 cards. Since the number of Cards in a Deck is fixed, we could use a
static array to hold the Cards of a Deck. Alternately, a vector can also be used to
hold the Cards in this Deck. The Deck should be able to shuffle itself when requested
and should also provide a getNextCard() method which is self explanatory.
Pile:
A Pile is also a collection of Cards but the number of Cards in a Pile may vary
during the play. A Game will contain several Piles. Different Games will have different
restrictions on various Piles they may contain. It would not always be possible to add
or remove a Card from a Pile. This will depend upon the current state of Piles and
the type of Game.
Since there can be many types of Piles, this class should behave as the base class from
which other Piles are able to derive. Perhaps, the best way to implement a Pile is to
encapsulate a deque/vector of Cards in it (we will prefer deques!). In fact, the
Cards are still the property of Deck and a Pile should only hold references to them.
Since an STL container can only hold real variables (and not the references), it is best to
store pointers to Cards in a Pile. Each Pile may only contain a maximum number of
Cards which should be passed as an int to the Pile constructor.
During the Games we implement, we will be moving Cards around one by one from one
Pile to another. Therefore, Piles should implement a method which tells whether or
not we can remove the top card from the Pile. If the Pile is not empty, this is usually
true unless some Pile overrides this behavior and removal is prohibited, either in
general or to a specific destination. Similarly, a Pile should be able to tell whether it
can receive the top Card from some other Pile.
One important property of a Pile is that it could either be circular or non-circular. The
former means that the Cards wrap around. For example, some Piles will require
starting from a particular rank but others will not. Other methods a Pile should
implement include, but are not limited to, getting the top Card, adding a Card,
removing a Card, and printing the Pile.
Another important property of a Pile is that it may be fanned or not. When the Pile is
not fanned, you could only see the top Card of the file and the other Cards underneath
are not visible. Of course, you couldn’t see a Card that is not facing up.
It would probably be a good idea to make the printPile() method public and the
printTopCard() method protected. This is because a specific Pile (perhaps a
subclass of Pile) will decide itself whether it is fanned or not.
Game:
The Game class implements a card game which can be played with one standard deck of
cards. Initial dealing of cards (distributing on various piles) is the property of a specific
Page 3 of 8
Game which will be derived from this class. Perhaps, a dealCards() method may be
defined in this class as pure virtual.
As we said, a Game will be a sequence of moves of a single Card from one Pile to
another. Once you move a Card, the Game should redraw itself, thus requiring a
redrawBoard() method. This is the best place to have an interface with the graphics
objects. You will write the redrawBoard() method but don’t worry about the
graphics interface unless you want to build a graphics version of the Game. Even if you
are making a graphics version, we suggest you finish the project with console output and
then build a graphics interface.
At the end of each move, the Game should be asked if the player has won the Game. For
all the Games we are implementing, there is only one way of winning the game: when
the player is able to move ALL Cards to four foundation piles; these Piles will derive
from the Pile base class. Thus, the goal in each Game we implement is to move all
the Cards to the foundation piles.
The Game class should also implement the main interactive loop where input is taken
from the user. This is the second place where graphics objects will interface. We will
provide you starter code for using the console input but feel free to modify it in any way
that pleases your aesthetic sense.
Other Helper Classes:
Perhaps you would want to have one SimpleInput class or something similar to that
and one class which acts as the entry point into the program. We will provide starter code
for the entry point in a file called solitaire.cpp
The Derived Classes
In addition to the base classes described above, you will have an inheritance hierarchy for
the two classes: Game and Pile.
Classes derived from the Game class will each represent a unique Game and the classes
derived from the Pile class will each represent a Pile with some special properties.
FoundationPile2
As we already mentioned, there are four foundation piles in each Game and they may be
encapsulated in the Game base class. The goal of each Game we write is to fill up the
four FoundationPiles, each carrying 13 Cards. The FoundationPiles derive
from the Pile class and may or may not be circular. If the FoundationPiles are
non-circular, they must start from a specific Card and build up3 on that Card (usually
the A of each suit). If they are circular, they may start at any Card location and building
up on top of that. For example, {4 3 2 A K Q J 10 9 8 7 6 5}4 is a valid circular
FoundationPile.
2 Definition from
http://www.goodsol.com/pgshelp/foundation.htm: Piles of cards where the object is to
build upon a base card, usually up in a sequence. In most games, the foundations are built up by suit,
although this can vary. Also, once cards are moved to foundations, usually they cannot be moved again.
Most solitaire games are won when all the cards have been moved to the foundations.
3 Play a card one rank higher and of the same suit on a card. For example, play a 5H on a 4H.
4 The convention we follow is that the right most card on screen is at the bottom of a pile. That is, the cards
are placed in a pile on top of the cards to their right on the console.