1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
|
* File: main.cpp
* Author: drami_000
*
* Created on April 4, 2015, 12:19 PM
*/
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;
/*
*
*/
int main(int argc, char** argv) {
srand(time(0));
int played_credits;
string player_name;
int ans;
int bet;
int balance;
//played_credits = balance;
int credits = 100;
cout << "\n*************** Welcome ***************\n"
<< "***************** to ******************\n"
<< "**************** Prism ****************\n\n";
cout << "Please enter your name: ";
cin >> player_name;
cout << "welcome " << player_name <<
", Please choose a game from the menu.\n\n";
{
cout << "----------------- Menu -----------------\n"
<< " 1. Slots.\n"
<< " 2. Blackjack.\n";
// << " 3. "
// << " 4. "
// << " 5. "
if(credits == 100){
cout << "Credits: $ " << credits << "\n" // The players balance
<< "Please enter the game you would like to play: ";
}
else if(balance > 100){
cout << "Credits: $ " << balance << "\n" // The players balance
<< "Please enter the game you would like to play: ";
}
else if(balance < 100){
cout << "Credits: $ " << balance << "\n" // The players balance
<< "Please enter the game you would like to play: ";
}
cin >> ans;
switch(ans){
case 1:
cout << "**************** 5 card poker ***************\n"
"************** good luck! *************\n";
int row1, row2, row3, row4, row5, row6, row7, row8, row9;
int pot1, pot2, pot3, pot4, pot5, pot6, pot7, pot8, pot9;//the slot machine.
{
if (credits == 100) {
cout << "\n\nCredits: $ " << credits << "\n"; // The players balance
} else if (balance > 100) {
cout << "\n\nCredits: $ " << balance << "\n"; // The players balance
} else if (balance < 100) {
cout << "\n\nCredits: $ " << balance << "\n"; // The players balance
}
cout << "Hello," << player_name <<
" .Please enter the amount you would like to bet\n"
<< "and then hit enter to pull the lever.\n"
<< "Bet amount: ";
cin >> bet;
balance = credits - bet;
pot1 = bet * 3 + 3; // pay outs for rows 1 and 2.
pot2 = bet * 4 + 9; //
pot3 = bet * 5 + 12; //
pot4 = bet * 6; // pot 4-6 are for the center row.
pot5 = bet * 8; //
pot6 = bet * 10; //
pot7 = bet * 3; // pot 7-9 are for winning diagonally.
pot8 = bet * 4; //
pot9 = bet * 5; //
row1 = rand() % 7; // generates a random number from 0-7 in each slot
row2 = rand() % 7; // for each row and column.
row3 = rand() % 7;
row4 = rand() % 7;
row5 = rand() % 7;
row6 = rand() % 7;
row7 = rand() % 7;
row8 = rand() % 7;
row9 = rand() % 7;
cout << "\n ======================\n";
cout << " ====================== @\n";
cout << " ===1~| " <<
row1 << " | " << row2 << " | " << row3 << " |==== |\n";
cout << " ===2~| " <<
row4 << " | " << row5 << " | " << row6 << " |==== |\n";
cout << " ===3~| " <<
row7 << " | " << row8 << " | " << row9 << " |==== |\n";
cout << " ==|================|== =\n";
cout << " ==|================|==\n";
cout << " ==|________________|==";
if (row1 == 0 && row2 == 0 && row3 == 0) {// first row
cout << "You won!\n";
cout << "\nPay out: " << pot1;
cout << "\nCredits: " << balance + pot1;
} else if (row1 == 3 && row2 == 3 && row3 == 3) {// first row
cout << "You won!\n";
cout << "\nPay out: " << pot2;
cout << "\nCredits: " << balance + pot2;
} else if (row1 == 7 && row2 == 7 && row3 == 7) {// first row
cout << "You won!\n";
cout << "\nPay out: " << pot3;
cout << "\nCredits: " << balance + pot3;
} else if (row4 == 0 && row5 == 0 && row6 == 0) {// middle row
cout << "You won!\n";
cout << "\nPay out: " << pot4;
cout << "\nCredits: " << balance + pot4;
} else if (row4 == 3 && row5 == 3 && row6 == 3) {// middle row
cout << "You won!\n";
cout << "\nPay out: " << pot5;
cout << "\nCredits: " << balance + pot5;
} else if (row4 == 7 && row5 == 7 && row6 == 7) {// middle row
cout << "You won!\n";
cout << "\nPay out: " << pot6;
cout << "\nCredits: " << balance + pot6;
} else if (row7 == 0 && row8 == 0 && row9 == 0) {// 3rd row
cout << "You won!\n";
cout << "\nPay out: " << pot1;
cout << "\nCredits: " << balance + pot1;
} else if (row7 == 3 && row8 == 3 && row9 == 3) {// 3rd row
cout << "You won!\n";
cout << "\nPay out: " << pot2;
cout << "\nCredits: " << balance + pot2;
} else if (row7 == 7 && row8 == 7 && row9 == 7) {// 3rd row
cout << "You won!\n";
cout << "\nPay out: " << pot3;
cout << "\nCredits: " << balance + pot3;
} else if (row1 == 0 && row5 == 0 && row9 == 0) {// diagonal left top
cout << "You won!\n";
cout << "\nPay out: " << pot7; // to bottom right.
cout << "\nCredits: " << balance + pot7;
} else if (row1 == 3 && row5 == 3 && row9 == 3) {// diagonal left top
cout << "You won!\n";
cout << "\nPay out: " << pot8; // to bottom right.
cout << "\nCredits: " << balance + pot8;
} else if (row1 == 7 && row5 == 7 && row9 == 7) {// diagonal left top
cout << "You won!\n";
cout << "\nPay out: " << pot9; // to bottom right.
cout << "\nCredits: " << balance + pot9;
} else if (row7 == 0 && row5 == 0 && row3 == 0) {// diagonal right top
cout << "You won!\n";
cout << "\nPay out: " << pot7; // to bottom left.
cout << "\nCredits: " << balance + pot7;
} else if (row7 == 3 && row5 == 3 && row3 == 3) {// diagonal right top
cout << "You won!\n";
cout << "\nPay out: " << pot8; // to bottom left.
cout << "\nCredits: " << balance + pot8;
} else if (row7 == 7 && row5 == 7 && row3 == 7) {// diagonal right top
cout << "You won!\n";
cout << "\nPay out: " << pot7; // to bottom left.
cout << "\nCredits: " << balance + pot7;
} else if (row1 != 0 && row1 != 3 && row1 != 7 || //
row2 != 0 && row2 != 3 && row2 != 7 || // lost.
row3 != 0 && row3 != 3 && row3 != 7 || // checks each row to
row4 != 0 && row4 != 3 && row4 != 7 || // see if it doesn't
row5 != 0 && row5 != 3 && row5 != 7 || // equal the winning
row6 != 0 && row6 != 3 && row6 != 7 || // rows. Then "couts"
row7 != 0 && row7 != 3 && row7 != 7 || // what you lost and
row8 != 0 && row8 != 3 && row8 != 7 || // remaining credits.
row9 != 0 && row9 != 3 && row9 != 7 || //
row1 != 0 && row5 != 3 && row9 != 7 ||
row7 != 0 && row5 != 3 && row3 != 7) {
cout << "\n\n Lost: " << bet << "\n";
cout << " Credits: " << balance << endl; //the credits you lost.
}
}
|