Find Jobs
Hire Freelancers

319534 Programming Project 491815

N/A

Completed
Posted almost 15 years ago

N/A

Paid on delivery
You are required to write a C++ program to simulate a simple card game. The rules of the game are the following: • A standard deck of 52 playing cards are dealt randomly to four players, each receives 13 cards. Cards rank from 2 (lowest) to A (highest). • Initially, one player is randomly chosen as the banker. A game runs in several rounds. • At each round, the banker plays a single card from his hand. The next player (clockwise) can choose either to “suppress” the card by playing a card with higher rank (disregarding suits) or to “pass” his turn to the next player. All players take turns until no player wants to suppress the current card (the desk card). The owner of the desk card becomes the banker of the next round. • A player wins if he finishes all his cards before any others. Task 1: Create a class called Card that represents a playing card. The class should include two private data items: value and suit. The member functions of the class should include, but not limited to, getValue(), setValue(int), getSuit(), setSuit(int) and displayCard() for accessing data members and display cards. Task 2: Create a class called Player to simulate a dummy player. The class should include at least two data items: playerName (string or char*) and CardsInHand (array or vector of Card objects). The class should implement at least the following member functions: setPlayerName (string or char*), getPlayerName(), addCard(Card), play(Card&). The strategy of playing a card can be as simple as giving the first available card in hand that can suppress the desk card. Task 3: Create a class called Game to simulate single game playing. The class should be able to: • Generate a deck of cards • Shuffle the deck • Deal the deck to each player • Randomly pickup one player as the banker before a game starts • Proceed with each round: collecting players' cards, updating information on the current banker and desk cards, taking turns and determining the winner and the banker. Task 4: Write an application (.cpp) to simulate game playing Note: An example program (executable file) in this level is downloadable ([login to view URL]). You do not have to follow exactly the way I did. Task 5: Create a class called SmartPlayer, which is a derived class of Player (inheritance). The class implements smarter playing strategies in order to win the players. Task 6: Change the application program in Task 4 to simulate multiple game playing. Set one of the players to be the SmartPlayer and play against dummy players. Your SmartPlayer should be able to win more than half of total games. Note: An example program (executable file) in this level is also downloadable ([login to view URL]). Task 7: Create a class called HumanPlayer, which is also a derived class of Player. HumanPlayer allows a human user to play against computer players (simply providing an interface for the user to input the card or cards to play). Task 8: Extend your program to allow a player to play multiple cards: • Twin: two cards in same rank • Triplets: three cards in same rank • Bomb: four cards in same rank A bomb can suppress any single, twin, triplets or a bomb in lower rank. A twin can only be suppressed by another twin in higher rank. Similar rules apply to triplets. You can also introduce more rules and design your own rules for this extension. There is no standard answer for this level of programs. Any good ideas and innovations are welcome and will be highly rewarded ( For instance, you can implement a SmarterPlayer with learning ability to learn from Human Player).
Project ID: 2065338

About the project

1 proposal
Remote project
Active 12 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
Greetings, Please see my detailed post on the PMB.
$100 USD in 3 days
0.0 (0 reviews)
0.0
0.0

About the client

Flag of
Sydney,
5.0
2
Member since May 14, 2009

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.