Untitled

 avatar
unknown
c_cpp
4 years ago
5.0 kB
5
Indexable
#include <iostream>
#include <ctime>
#include <math.h>
#include <stdlib.h>
#include <fstream>
#include <string.h>
#include <string>

using namespace std;

struct MyGame
{
	char PlayerName[20];
	int GameNo = 1;
	int pScore = 10;
	int cScore = 10;
};

void CompHide(char Chide)
		{
			switch(Chide)
			{
				case 'o':
					cout << "\tThe Computer has hide three marbles." << endl;
					cout << "                                    " << endl;
					cout << "      ***         ***         ***   " << endl;
					cout << "    *******     *******     ******* " << endl;
					cout << "    *******     *******     ******* " << endl;
					cout << "    *******     *******     ******* " << endl;
					cout << "      ***         ***         ***   " << endl;
					cout << "                                    " << endl;
					break;
				case 'e':
					cout << "\tThe Computer has hide two marbles." << endl;
					cout << "                                      " << endl;
					cout << "      ***                    ***      " << endl;
					cout << "    *******                *******    " << endl;
					cout << "    *******                *******    " << endl;
					cout << "    *******                *******    " << endl;
					cout << "      ***                    ***      " << endl;
					cout << "                                      " << endl;
					break;
				return;
			
			}
		}
void PlayerPick(char Ppick)
	{
					switch(Ppick)
				{
					case 'o':
					case 'O':
						cout << "\n\n\tYou have chosen Odd." << endl;
						break;
					case 'e':
					case 'E':
						cout << "\n\n\tYou have chosen Even." << endl;
						break;
				}
	}
void PlayerHide(char Phide)
	{
					switch (Phide)
					{
					case '2':
						cout << "\n\n\tYou have hide two marbles."       << endl;
						cout << "                                      " << endl;
						cout << "      ***                    ***      " << endl;
						cout << "    *******                *******    " << endl;
						cout << "    *******                *******    " << endl;
						cout << "    *******                *******    " << endl;
						cout << "      ***                    ***      " << endl;
						cout << "                                      " << endl;
						break;
					case '3':
						cout << "\n\n\tYou have hide three marbles."  << endl;
						cout << "                                    " << endl;
						cout << "      ***         ***         ***   " << endl;
						cout << "    *******     *******     ******* " << endl;
						cout << "    *******     *******     ******* " << endl;
						cout << "    *******     *******     ******* " << endl;
						cout << "      ***         ***         ***   " << endl;
						cout << "                                    " << endl;
						break;
					}	
	}
void ComputerPick(char Cpick)
	{

					switch(Cpick)
					{
					case 'o':
						cout << "\tThe Computer has picked Odd!!" << endl;
						break;
					case 'e':
						cout << "\tThe Computer has picked Even!!" << endl;
						break;
					}
	}	
unsigned int RandomNo()
	{

		float x;
		unsigned int y;
			srand((unsigned)time(NULL));
			x = rand();
			x = (sin(rand())*363364);
			y = x;
			return y;
	}
void PlayerHand(char &player)
	{
			cout << "\n\n\tPlease Pick Odd or Even [o/e]: ";
			cin >> player;
			cin.ignore();
	}
void ComputerHand (char &computer, unsigned int y)
	{
		int modComp;
		
			modComp = y%2;		
			if((modComp==0))
				computer = 'e';
			else if ((modComp==1))
				computer = 'o';
	}
void ComputerMarb (char &computer, unsigned int y)
	{
		int modComp;
			modComp = y%2;	
			modComp = y;
			if((modComp==0))
				computer = 'e';
			else if ((modComp==1))
				computer = 'o';

	}
void WinsPick (char player, char computer, MyGame &x)
	{
		
			if((player=='o')&&(computer=='o')||
			(player=='O')&&(computer=='o')||
			(player=='e')&&(computer=='e')||
			(player=='E')&&(computer=='e'))
			{
				cout << "\n\n\tYey! Your guess was right " << x.PlayerName << "! You have gained two marbles.\n\n\n\n\n\n\n";
				x.pScore++;
				x.pScore++;
				x.cScore--;
				x.cScore--;
			}
			else if((player=='o')&&(computer=='e')||
			(player=='O')&&(computer=='e')||
			(player=='e')&&(computer=='o') ||
			(player=='E')&&(computer=='o'))
			{
				cout << "\n\n\tOh no! You lose " << x.PlayerName << "! The computer took your two marbles.\n\n\n\n\n\n\n";
				x.cScore++;
				x.cScore++;
				x.pScore--;
				x.pScore--;
			}
	}
void WinsHide (int marb, char computer, MyGame &x)
	{

						if((marb=='2')&&(computer=='o')||
						(marb=='3')&&(computer=='e'))

							{
							cout << "\n\n\n\tYey! The Computer has lost " << x.PlayerName << "! You have gained two marbles.";
							x.pScore++;
							x.pScore++;
							x.cScore--;
							x.cScore--;
							}
						else if((marb=='2')&&(computer=='e')||
						(marb=='3')&&(computer=='o'))
							{
							cout << "\n\n\n\tOh no! The Computer has won " << x.PlayerName << "! The computer took your two marbles.";
							x.cScore++;
							x.cScore++;
							x.pScore--;
							x.pScore
Editor is loading...