-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGocApp.cpp
More file actions
63 lines (51 loc) · 937 Bytes
/
GocApp.cpp
File metadata and controls
63 lines (51 loc) · 937 Bytes
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
#include "Goc.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
enum Status {CONTINUE, WON, LOST}; //gamestatus
Status gameStatus;
int sum, mypoints;
srand(time(NULL));
sum = rolldice(); // first time rolling
switch(sum)
{
case 7: //first roll won
case 11:
gameStatus = WON;
break;
case 2:
case 3:
case 12:
gameStatus = LOST; //first roll lost
break;
default:
gameStatus = CONTINUE; //continue to play
mypoints = sum;
cout << "MY Points: "<< mypoints<<"\n"<<endl;
break;
}
while(gameStatus == CONTINUE)
{
sum = rolldice(); //rolling again
if(sum == mypoints) //win by making player point
{
gameStatus = WON;
}
else if(sum == 7) //lost by rolling 7!
{
gameStatus = LOST;
}
}
if (gameStatus == WON)
{
cout << "Player Won!!."<<endl;
}
else
{
cout <<"Player Lost!!"<<endl;
}
return 0;
}