Professional Documents
Culture Documents
5
CPEPROGLA1
JACK AND POY GAME
GRADE
Professor
CODE COMPILATION:
// This programs shows a Jack and Poy game.
#include<iostream>
#include<string.h>
#include<windows.h>
using namespace std;
WORD GetConsoleTextAttribute (HANDLE hCon)
{
CONSOLE_SCREEN_BUFFER_INFO con_info;
GetConsoleScreenBufferInfo(hCon, &con_info);
return con_info.wAttributes;
}
int main ()
{
// Personal information of the programmer
cout << "Maria Kristel Zaira G. Maca" << endl;
cout << "BSME K-23" << endl;
char X; // Rock
char Y; // Paper
char W; // Scissors
char P1; // Player one
char P2; // Player two
int a=0; // Score 1
int b=0; // Score 2
int c; // Rounds
char choice[10];
cout << "Choose player number: \nPlayer 1 or Player 2?" <<endl;
cin.getline(choice,10);
for (c=1;c<=10;c++)
{
m:
cout << "Player 1: ";
cin >> P1;
cout << "Player 2: ";
cin >> P2;
// Applicable for small letters only.
if ((P1=='y') && (P2=='x') || (P1=='y') && (P2=='w') || (P1=='w') && (P2=='x'))
{
a++;
cout << "Player 2 WINS" << endl;
cout << "Score " << a << endl;
}
else if ((P1=='x') && (P2=='y') || (P1=='w') && (P2=='y') || (P1=='x') &&
(P2=='w'))
{
b++;
cout << "Player 1 WINS" << endl;