Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CSE294B Assignment #2: Building a Poker Game with Multiple Files and Classes - Prof. Jeffr, Assignments of Engineering

An assignment for a computer science course (cse294b) where students are required to build a poker game using classes and multiple files. The assignment involves creating three classes: a deck, a player, and a dealer. The deck class will handle shuffling, dealing, and other related functions. The player class will manage player actions such as checking, folding, betting, and raising. The dealer class will determine the winner and keep track of bets. Students must ensure that each player starts with $1000 and bets $10 at the beginning of each hand, with additional betting opportunities after being dealt their cards and after each new card is revealed. The game continues until the user inputs 0 as the number of players.

Typology: Assignments

2009/2010

Uploaded on 03/28/2010

koofers-user-v6z
koofers-user-v6z 🇺🇸

3.7

(2)

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSE294B Assignment #2
Professor Miller
1/3
CSE294B Assignment #3
3.0% of course grade
Thisassignmentisgoingtogiveyouexperiencewritingaprogramwithclassesand
multiplefiles.YouwillbuildonAssignment#2forthisassignment.
YouwilladdthreeclassesintoyourprogramfromAssignment#2.Oneoftheclasses
willrepresentadeckandallfunctionsthatcanbeperformedonit(suchasshuffle,deal,
flop,river,turn,etc.).Thesecondclasswillrepresentaplayerandallfunctionsthatcan
beperformedonorbyaplayer(suchaspromptingforchecking,folding,betting,etc.).
Thethirdclasswillrepresentthedealer,whosejobistodeterminethewinnerbasedon
thecardsandkeeptrackofallofthebets.Thedealerclassisgoingtocontainthecode
thatkeepstrackoftheflowofthegame,butmustcallfunctionsintheotherclasses.
Wewillnotbeperformingthecomparisonsonthehandsyetinthisassignment,soyou
stillwillnotknowwhichplayeractuallywins.Wewilladdintheabilityforaplayerto
fold,bet,orraisethough.Eachplayerwillstartwith1000dollarsandmustbet10
dollarsatthebeginningofthehand.Therearefourothertimeswhenplayerscanbet:
aftertheyaredealttheirtwocards,aftertheflop,aftertheturn,andaftertheriver.A
playercanbetin10dollarincrements,wherethefirstplayercanonlybet10dollars,but
thenasubsequentplayercanbeteither10dollarsorraiseto20dollars.Ifthenext
playerraisedto20dollars,thenextplayermustbet20dollarsorraiseto30dollars.If
theplayerdoesnotwanttobet20dollarsorraiseto30dollars,hemustfold.Bythe
timeeachbettingroundhasconcluded,alloftheplayersthathavenotfoldedmust
havebetthesameamountofmoney.
Oneadditionalrequirementwillbeforyourprogramtocontinuelooping,promptingfor
howmanyplayersthereareattheendofeachhand.Thisshouldnotstopuntiltheuser
types0asthenumberofplayers.
Thelettersusedbytheplayersareasfollows:f=fold,z=check,b=bet,c=call,r=
raise.Inparentheses,onlytheoptionsavailabletotheplayerareincluded,asaplayer
cannotdoanyoftheoptionsatanytime.Herearetherulesforwhatoptionstheplayer
hasavailable:
Aplayercanonlycheck(z)orbet(b)ifhealreadyhasthesameamountofmoneyinthe
potastheplayerwhohasthemostmoneyinthepot.
Aplayercancall(c)orraise(r)ifhehaslessmoneyinthepotthantheplayerwhohas
themostmoneyinthepot.Ifhecalls,hewillputthesameamountofmoneyinthepot
astheplayerwhohasthemostamountofmoneyinthepot.Ifheraises,hewillraise
for10dollarsmorethantheamountinbytheplayerwhohasthemostmoneyinthe
pot.
Aplayercanfold(f)atanytime,thoughhedoesnotgetanyofhismoneybackthathe
hasalreadyputintothepot.
pf3

Partial preview of the text

Download CSE294B Assignment #2: Building a Poker Game with Multiple Files and Classes - Prof. Jeffr and more Assignments Engineering in PDF only on Docsity!

CSE294B Assignment # Professor Miller

CSE294B Assignment # 3.0% of course grade

This assignment is going to give you experience writing a program with classes and multiple files. You will build on Assignment #2 for this assignment.

You will add three classes into your program from Assignment #2. One of the classes will represent a deck and all functions that can be performed on it (such as shuffle, deal,

flop, river, turn, etc.). The second class will represent a player and all functions that can

be performed on or by a player (such as prompting for checking, folding, betting, etc.). The third class will represent the dealer, whose job is to determine the winner based on

the cards and keep track of all of the bets. The dealer class is going to contain the code

that keeps track of the flow of the game, but must call functions in the other classes.

We will not be performing the comparisons on the hands yet in this assignment, so you

still will not know which player actually wins. We will add in the ability for a player to fold, bet, or raise though. Each player will start with 1000 dollars and must bet 10

dollars at the beginning of the hand. There are four other times when players can bet:

after they are dealt their two cards, after the flop, after the turn, and after the river. A player can bet in 10 dollar increments, where the first player can only bet 10 dollars, but

then a subsequent player can bet either 10 dollars or raise to 20 dollars. If the next player raised to 20 dollars, the next player must bet 20 dollars or raise to 30 dollars. If

the player does not want to bet 20 dollars or raise to 30 dollars, he must fold. By the

time each betting round has concluded, all of the players that have not folded must have bet the same amount of money.

One additional requirement will be for your program to continue looping, prompting for how many players there are at the end of each hand. This should not stop until the user

types 0 as the number of players.

The letters used by the players are as follows: f = fold, z = check, b = bet, c = call, r =

raise. In parentheses, only the options available to the player are included, as a player

cannot do any of the options at any time. Here are the rules for what options the player has available:

A player can only check (z) or bet (b) if he already has the same amount of money in the pot as the player who has the most money in the pot.

A player can call (c) or raise (r) if he has less money in the pot than the player who has the most money in the pot. If he calls, he will put the same amount of money in the pot

as the player who has the most amount of money in the pot. If he raises, he will raise

for 10 dollars more than the amount in by the player who has the most money in the pot.

A player can fold (f) at any time, though he does not get any of his money back that he

has already put into the pot.

CSE294B Assignment # Professor Miller

Here is what the output of this program should be:

How many players are there? 4

Player 1 has bet 10 dollars. Player 2 has bet 10 dollars. Player 3 has bet 10 dollars. Player 4 has bet 10 dollars.

Player 1: Jack of Spades, 2 of Diamonds Player 2: 9 of Clubs, 6 of Clubs Player 3: Ace of Hearts, Ace of Diamonds Player 4: Ace of Clubs, Queen of Spades

Player 1: What would you like to do (f, z, b)? z Player 1 checks. Player 2: What would you like to do (f, z, b)? b Player 2 bets 10 dollars. Player 3: What would you like to do (f, c, r)? c Player 3 calls 10 dollars. Player 4: What would you like to do (f, c, r)? r Player 4 raises to 20 dollars. Player 1: What would you like to do (f, c, r)? f Player has folded Player 2: What would you like to do (f, c, r)? c Player 2 calls 20 dollars. Player 3: What would you like to do (f, c, r)? c Player 3 calls 20 dollars.

Flop: 3 of Diamonds, 5 of Clubs, 9 of Spades

Player 2: What would you like to do (f, z, b)? b Player 2 bets 10 dollars. Player 3: What would you like to do (f, c, r)? c Player 3 calls 10 dollars. Player 4: What would you like to do (f, c, r)? c Player 4 calls 10 dollars.

Turn: Ace of Spades

Player 2: What would you like to do (f, z, b)? z Player 2 checks. Player 3: What would you like to do (f, z, b)? z Player 3 checks. Player 4: What would you like to do (f, z, b)? z Player 4 checks.