![]() |
| ||
| Simple Craps Game 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)) I just can't figure out how to make it two players. Also I'm supposed to use the rand function for one die to determine which player goes first. Heres what I've got. Any help would really be appreciated. ================================================ /* header files */ |
| ||
| Re: Simple Craps Game Quote:
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. |
| All times are GMT -4. The time now is 3:27 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC