I have a assignment with these details may some one please help me on this?!?
This is the assignment:
The rules of craps are as follows (basic rules, not casino rules).
On the first roll, if the player rolls a 7 or 11, they win. If a player rolls a 2, 3 or 12 they lose.
If a player does not win or lose on the first roll, that total establishes the "point".
The player then continues to roll until, the "point" is rolled, in which case he wins or a 7 is rolled, in which case he loses. There is no limit on the number of subsequent rolls. Just keep rolling until a 7 or the "point" is rolled.
If the player's point is an even number (4, 6, 8, 10) ask if he wants to bet the "hard way". If so, prompt for bet. The "hard way" is a one roll bet that pays double the wager if he gets his points with a pair. For example, if his point is 10, the hard way is a roll of 5 and 5. Remember, it is a one roll bet, unlike the regular game described above in which he can roll many times before he loses or wins.
Once a player wins or loses, that is a game and it all starts over unless he wants to cash out.
You will allow the player to set up a bankroll at the beginning of the program, require him to bet before each game (bets cannot be <= 0 or > available bankroll), and inform him of what is rolled each time, whether he wins or loses and if he doesn't win or lose, remind him of his point. Add or subtract the bet according to/from his bankroll. After each game, prompt the user and ask if he wants to play again or cash out.
If he plays again, start a game all over, he wants to cash out, tell him how much he has in his bankroll and say goodbye.
So, I see the logic flow like this...
Prompt for bankroll
Repeat the following for each game
...clear the screen
...ask for bet (check for valid bet. Keep ...prompting until valid bet is entered)
...roll the dice
...Display 3D ascii dice(use are dice roll header file, but at the end of the rolls, display the appropriate value ……………………………on the dice). Roll for about 3 seconds and then display the outcome. Roll fast so that ……………………………values can’t be seen while rolling)
...switch
......2,3,12
......... you lose (deduct bet from bankroll)
......... inform player
......7, 11
..........you win, (add bet to bankroll)
..........inform player
......otherwise
..........set point
..........inform player
……....if point is n even number...ask if he wants to bet the "hard way"
..If no win or lose
......continue to roll until point (win) or 7 (lose)
……pay or deduct the “hard way” for a single roll
......manipulate bankroll accordingly
...prompt to play again or cash out
...if play again
......prompt for bet and repeat code (loop)
...if cash out
......tell the player how much he has
......say goodbye
Note: Clear the screen between all rolls.
I need at least 3 functions with parameters and/or return values. What the functions do is up to you. You should really consider using as many functions as would make sense. Let's keep main() clean. All functions must have prototypes. No globals.
I have no 3 Dimensional Dice, and I have no bet / hard way "system" but I have a Dice roll algorithm and I need help on the rest...
#include <iostream>
#include <ctime>
#include <limits>
using namespace std;
int main()
{
srand(time(0)); //seeds random generator
int die1, die2 = 0; //you can put them together to make it smaller + neater
int roll1;
char repeat = 'y'; //when declaring a char with a letter you have to put ' ' around it
cout << "Welcome. The game is about to begin." << endl;
while (repeat == 'y' || repeat == 'Y') //still needs ' '
{
cin.ignore(numeric_limits<streamsize>::max(), '\n'); //recommend this instead of system("PAUSE") you will need '#include <limits>"
//you can find why this is better in a long thread somewhere in these forums
die1 = rand() % 6 + 1;
die2 = rand() % 6 + 1; //dont need brackets around rand()
roll1 = die1 + die2;
cout << "Your roll was: " << die1 << " + " << die2 << " = " << roll1 << endl;
if (roll1 == 7 || roll1 == 11)
{
cout << "You WON! Would you like to play again? [Y/N]: " ;
cin >> repeat;
system("cls");
} //what happens if it's 7, 11 roll;
else if (roll1 == 2 || roll1 == 3 || roll1 == 12)
{
cout << "Sorry, you LOST! Would you like to play again? [Y/N]: " ;
cin >> repeat;
system("cls");
} //what happens if it's 2, 3 or 12 roll;
else if (roll1 == 4 || roll1 == 6 || roll1 == 8 || roll1 == 10)
{
cout << "You rolled a " << roll1 << " Would you to bet the hard way? [Y/N]: " ;
cin >> repeat;
system("cls");
} //what happens if it's 4, 6, 8 or 10 roll;
}
return(0);
}