-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
93 lines (77 loc) · 1.81 KB
/
main.cpp
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
#include <iostream>
#include <cstring>
#include <vector>
#include <fstream>
#include <ctime>
#include <tuple>
#include "card.hpp"
#include "player.hpp"
#include "dealer.hpp"
using namespace std;
void clrscr() {
system("clear");
}
// deal card for both
bool deal(Player &p1, Dealer &d1) {
bool player = p1.addCard();
bool dealer = true;
if(d1.getSum() < 18){
dealer = d1.addCard();
}
return (player && dealer);
}
void printDeck(vector<Card>& d) {
for(auto el:d) {
cout<<el.getNumber()<<" ";
}
cout<<endl;
}
int main() {
clrscr();
srand(time(NULL));
char name[100];
char choice, hit='Y';
bool status;
int k=1;
vector<Card> deck(52);
for(int i=0;i<52;i++) {
deck[i].setNumber(k++);
}
printDeck(deck);
int val= rand()%52;
cout << deck[val].getNumber() << endl;
cout<<deck.size()<<endl;
deck.erase(deck.begin()+val);
printDeck(deck);
cout<<deck.size()<<endl;
// cout << "Hello! Enter your name: ";
// cin >> name;
// Player player(name);
// Dealer dealer;
// clrscr();
// cout<<"Hello! "; player.printName();
// while(hit!='N' and hit!='n') {
// status = deal(player,dealer);
// cout<<"\nYou hold: "<<player.getSum();
// cout<<"\nDealer holds: "<<dealer.getSum();
// if(status){
// cout<<"\nHit? : "; cin>>hit;
// }
// else {
// cout<<"\nGame ended.";
// break;
// }
// }
// if(status) {
// if(dealer.getSum() > player.getSum()) {
// cout<<"\nDealer wins";
// }
// else if(dealer.getSum() == player.getSum()) {
// cout<<"\nNeutral";
// }
// else{
// cout<<"\nYou win!";
// }
// }
return 0;
}