All pastes #1340734 Raw Edit

Anonymous

public cpp v1 · immutable
#1340734 ·published 2009-02-18 04:00 UTC
rendered paste body
/* * Player.cpp * * Assignment 4, Craps * SID: 995050550 * Author: Crystal Tse * Due: February 17, 2009 * Class: ECS 40, Winter 2009 */#include "Player.h"Player :: Player()				// default constructor{	wallet = 10000;				// player starts out with $10,000 in his wallet	currentBet = 1;				// initial bet is always $1	totalBet = 0;				// total bet in beginning is $0	numWon = 0;	numLost = 0;	numGames = 0;	decision = ' ';}Player :: ~Player()				// destructor{}void Player :: betOneDollar()			// betting rule: bets one dollar before each roll{	if((wallet-currentBet) <= 0)		// if player is broke	{		lose();	}	else	{		totalBet += currentBet;		// adds the current bet to total bet		wallet = wallet - currentBet;	// subtracts current bet from wallet	}}void Player :: betDouble()			// betting rule: doubles bet before each roll{		if((wallet-currentBet) <= 0)            // if player is broke	{		lose();	}	else	{		totalBet += currentBet;		// adds the current bet to total bet		wallet = wallet - currentBet;	// subtracts the current bet from wallet		currentBet *= 2;		// doubles current bet	}}int Player :: getNumGames(){	return numGames;}int Player :: getBet(){	return currentBet;}int Player :: getWallet(){	return wallet;}int Player :: getWins(){	return numWon;}int Player :: getLosses(){	return numLost;}void Player :: win(){	wallet += totalBet*2;	numWon++;	numGames++;}void Player :: lose(){	numLost++;	numGames++;	currentBet = 1;				// reset currentBet to 1}char Player :: getDecision(){	return decision;}