#include iostream
#include time.h
#include stdlib.h
#include windows.h
#include conio.h
void one();
void two();
void three();
void four();
void five();
void six();
int main()
{
short unsigned int score = 0;
short unsigned int compScore = 0;
short unsigned int num = 0;
short unsigned int num2 = 0;
short unsigned int compNum = 0;
short unsigned int compNum2 = 0;
short unsigned int sum = 0;
short unsigned int compSum = 0;
char letter;
srand(time(NULL));
system("title Je Dice Game");
while (letter != 'q')
{
cout << "Your Score: " << score << "\n";
cout << "computer's Score: " << compScore << "\n\n";
cout << "Press r to roll or q to quit: ";
cin >> letter;
num = 1 + rand() % (6 - 1 + 1);
num2 = 1 + rand() % (6 - 1 + 1);
compNum = 1 + rand() % (6 - 1 + 1);
compNum2 = 1 + rand() % (6 - 1 + 1);
sum = num + num2;
compSum = compNum + compNum2;
if (letter == 'q')
break;
if (letter != 'r')
{
system("cls");
continue;
}
switch (num)
{
case 1:
one();
break;
case 2:
two();
break;
case 3:
three();
break;
case 4:
four();
break;
case 5:
five();
break;
case 6:
six();
break;
default:
cout << "Error...";
break;
}
switch (num2)
{
case 1:
one();
break;
case 2:
two();
break;
case 3:
three();
break;
case 4:
four();
break;
case 5:
five();
break;
case 6:
six();
break;
default:
bout << "Error...";
break;
}
cout << "\nYours: " << num << ", " << num2 << "\n";
cout << "Computer's: " << compNum << ", " << compNum2 << "\n\n";
if (sum > compSum)
{
cout << "You won!!\n\n";
score++;
}
else
{
compScore++;
cout << "you lost...\n\n";
}
system("pause");
system("cls");
if (score == 12)
{
MessageBox(0, "You Won!!!", "Results:", MB_ICONEXCLAMATION);
break;
}
if (compScore == 12)
{
MessageBox(0, "You lost...", "Results:", MB_ICONEXCLAMATION);
break;
}
}
getche();
}
void one()
{
cout << "-----\n";
cout << "| |\n";
cout << "| O |\n";
cout << "| |\n";
cout << "-----\n";
}
void two()
{
cout << "-----\n";
cout << "| O|\n";
cout << "| |\n";
cout << "|O |\n";
cout << "-----\n";
}
void three()
{
cout << " -----\n";
cout << "| O|\n";
cout << "| O |\n";
cout << "|O |\n";
cout << " -----\n";
}
void four()
{
cout << " -,---\n";
cout << "|O O|\n";
cout << "| |\n";
cout << "|O O|\n";
cout << " -----\n";
}
void five()
{
cout << " -----\n";
cout << "|O O|\n";
cout << "| O |\n";
cout << "|O O|\n";
cout << " -----\n";
}
void six()
{
cout << " -----\n";
cout << "|O O|\n";
cout << "|O O|\n";
cout << "|O O|\n";
cout << " -----\n";
}
SEARCH
LATEST
3-latest-65px
Pengunjung
Categories
Refensi
(30)
Assistant of Laboratory
(18)
Linux
(13)
Keamanan Jaringan
(12)
bitcoin
(10)
Tip dan trik
(9)
Toko
(6)
Umsida
(6)
CCNA
(5)
C++
(4)
Driver
(3)
Materi
(3)
Rasberry Pi
(3)
Hardware
(2)
Uang
(2)
hadist
(2)
Kata-Kata
(1)
Keygen
(1)
Konfrimasi
(1)
adsense
(1)
mining
(1)
proxy
(1)
ranni
(1)