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
|
#include <iostream>
#include <stdlib.h>
#include <ctime>
#include <string>
using namespace std;
//calling decleration of welcome screen
void Welcome_Screen ();
//decleration of random values function
void User(int& a, int& b);
void Special_VALUES(int& c, int& d);
void ValueOfTen(int& e, int& f);
void SingleCard_Pickup(int& g, int& h);
//size of array being declared and arrys
int Array_Cards [] = {2,3,4,5,6,7,8,9,10,10,10,10,11,2,3,4,5,6,7,8,9,10,10,10,10,11,2,3,4,5,6,7,8,9,10,10,10,10,11,2,3,4,5,6,7,8,9,10,10,10,10,11};
string Suits [] = {"Clubs","Spades","Diamonds","Hearts"};
string Tens [] = {"King","Queen","jack","jack1"};
string choice ;
int main(){
srand(time(NULL)) ;
int values = 1;
int w,x,y,z,u,v,t,s;
int total;
int cardNo = 0 ;
Welcome_Screen();
cout << "Select enter key to begin"<<endl;
User(w,x);
Special_VALUES(y,z);
ValueOfTen(u,v);
SingleCard_Pickup(t,s);
cout <<"You pick up two cards"<<endl;
cout << "Your Values are "<<endl;
if (w == 10 && x != 10){
cout << "Card 1: " <<Tens[u] << " of " <<Suits[y] <<endl ;
cout << "Card 2: " <<Array_Cards[x] << " of " <<Suits[z] <<endl ;
}
else if (x == 10 && w != 10){
cout << "Card 1 : " <<Tens[v] << " of " <<Suits[z] <<endl ;
cout << "Card 2 : " <<Array_Cards[w] << " of " <<Suits[y] <<endl ;
}
else if (x == 10 && w == 10){
cout << "Card 1 : " <<Tens[u] << " of " <<Suits[z] <<endl ;
cout << "Card 2 : " <<Tens[v] << " of " <<Suits[y] <<endl ;
}
else if (x != 10 && w != 10) {
cout << "Card 1 : " <<Array_Cards[w] << " of " <<Suits[y] <<endl ;
cout << "Card 2 : " <<Array_Cards[x] << " of " <<Suits[z] <<endl ;
}
cardNo = 2;
total = Array_Cards[w] + Array_Cards[x];
cout << "Your total so far is " << total;
cout <<" Do you want to hold or hit? "<<endl;
cout <<"(Please enter either hold or hit) " <<endl;
cin >> choice ;
if (choice == "hit"){
cardNo ++;
cout << "You draw ";
cout<<"Card" <<cardNo <<" : " <<Array_Cards[t]<<" of " <<Suits[s] <<endl ;
total = total + Array_Cards[t];
cout << "Your total so far is " << total <<endl;
if(total <=21){
cardNo ++;
cout <<" Do you want to hold or hit? "<<endl;
cout <<"(Please enter either hold or hit) " <<endl;
cin >> choice;
if(choice == "hit"){
SingleCard_Pickup(t,s);
Special_VALUES(y,z);
cout <<"You draw" <<endl;
cout <<"Card" <<cardNo <<" : " << Array_Cards[t] <<" of "<<Suits[y] <<endl;
total = total + Array_Cards[t];
cout << "Your total so far is " << total <<endl;
}
}
else if (total > 21){
cout << "You have exceeded 21, computers turn" <<endl;
}
}
return 0;
}
void User(int& a, int& b){
a = rand() %51 ;
b = rand() %51 ;
}
void Welcome_Screen(){
cout <<"\t\t\t******************************\t\t\t\t"<<endl;
cout <<"\t\t\t**** ****\t\t\t\t"<<endl;
cout <<"\t\t\t*****Welcome to Blackjack*****\t\t\t\t"<<endl;
cout <<"\t\t\t**** Powered by Rnjesus ****\t\t\t\t"<<endl;
cout <<"\t\t\t******************************\t\t\t\t"<<endl;
}
void Special_VALUES(int& c,int& d){
c = rand()%3;
d = rand()%3;
}
void ValueOfTen(int& e, int& f){
e = rand()% 3;
f = rand()% 3;
}
void SingleCard_Pickup(int& g, int& h){
g = rand() %51 ;
h = rand() %3;
}
|