View Single Post
Join Date: Nov 2008
Posts: 377
Reputation: StuXYZ is a glorious beacon of light StuXYZ is a glorious beacon of light StuXYZ is a glorious beacon of light StuXYZ is a glorious beacon of light StuXYZ is a glorious beacon of light StuXYZ is a glorious beacon of light 
Solved Threads: 69
StuXYZ StuXYZ is offline Offline
Posting Whiz

Re: Simple Craps Game

 
0
  #2
Dec 3rd, 2008
Originally Posted by thinfineline View Post
I'm trying to get the game below to work with 2 players. It's setup the way I need it (even the entering the numbers for the die instead of using a rand function and not allowing the bet amount to change(crazy teacher))
First off you teacher is trying to save you some complexity. Complexity KILLS.

Second, Assuming that you seem to have done some c++. I think this is an excellent example of the break between old-style procedural programming and the beginnings of object orientated programming.
You can to this problem in a procedural way BUT it is easier to do it in an OO manor.

Thirdly. I suspect that you were initially asked to write a craps game and then asked to modify, which reinforces the difference. It is important that those who started very OO at the beginning are laughing and those that didn't are facing a big re-write.

Solution:

What all mathematicians know (instinctively), is that there are only
three number 0, 1, and infinity. 0 is an easy case (no-code) and 1 is what you currently have. 2 or many makes no difference it is the same.

For example you have a variable BankBalance. What you want is a BankBalance for every player, you have a Wager, you want one for every player.

You need to do several things.

(a) write a class for player. That has the things that are associated to the player.

(b) modifiy game method that acts on a player class.

(c) Manage the program so that you create 2 or however many players that are required and interact with the program.

Finally look up rand() and that will tell you how to get a random number for the dice throw. However, as has been discussed on recent threads rand() is not truly random but good enough for this project.
Reply With Quote