-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzar_oyunu_odev.cpp
executable file
·72 lines (65 loc) · 1.16 KB
/
zar_oyunu_odev.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
#include <iostream>
#include<ctime>
#include<cstdlib>
//#include <cstdlib>
using namespace std;
//__________________________________________________________________________________________
class Zar
{
int yuzey;
public:
void ZarAt()
{
int sayi;
srand(time(0));
sayi=(rand()%6)+1;
yuzey=sayi;
}
int sonuc()
{
ZarAt();
int _z=this->yuzey;
return _z;
}
};//class Zar
class Oyun
{
Zar z1,z2;
static int puan;
public:
Oyun(int _z1,int _z2)
{
_z1=z1.sonuc();
_z2=z2.sonuc();
}
void oyna()
{
//int _z1=1,_z2=1;
Oyun.z1;
for(int i=1;Oyun.z1+Oyun.z2>1;i++)
{
static int puanSorgula;
z1.sonuc();
z2.sonuc();
if(_z1==_z2 && _z1+_z2!=12)
{
puanSorgula+10;
cout<<'['<<i<<']'<<"Zar1="<<_z1<<'\t'<<"Zar2="<<_z2<<"Puan="<<puanSorgula<<endl;
}
else
cout<<'['<<i<<']'<<"Zar1="<<_z1<<'\t'<<"Zar2="<<_z2<<"Puan="<<puanSorgula<<endl;
if(_z1+_z2==12)
{
cout<<'['<<i<<']'<<"Zar1="<<_z1<<'\t'<<"Zar2="<<_z2<<endl;
cout<<"Game Over";
cout<<"Toplam Puan="<<puanSorgula;
break;
}
}//for döngüsü
}
};//class Oyun
int main()
{
Oyun o1;
o1.oyna();
}