Okay fine, here is the code, there is like 500+ lines...
Code:
#include <iostream> //cout & cin function
#include <cstdlib>
#include <string>
#include <windows.h> //system functions
#include <conio.h>
#include <stdio.h>
using namespace std;
void MENU(); //Decides what option to execute
void EXIT(); //Gives variable to exit
void RorQ(); //Decides to restart or quit
void clrscr(); //Clears the screen
class variable
{
public:
int I;
int menu; //Variable for deciding the option
char rq[1]; //Variable for 'r' or 'q' (restart or quit)
int exit;
};
class variable C; //Assigns class to C
void setcolor(unsigned short color)
{
HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hCon,color);
}
int main()
{
C.I = 2;
setcolor(C.I); // changes the color
cout << "++++++++++++++++ ++++++++++++++++ ++++++++++++++++\n";
cout << "+ + + + + +\n";
cout << "++++++ ++++++ ++++++ ++++++ + +++++++++++\n";
cout << " + + + + + + \n";
cout << " + + + + + + \n";
cout << " + + + + + + \n";
cout << " + + + + + + \n";
cout << " + + + + + + \n";
cout << " + + ++++++ ++++++ + +++++++++++\n";
cout << " + + + + + +\n";
cout << " ++++++ ++++++++++++++++ ++++++++++++++++\n";
cout << "\n\n";
cout << "++++++++++++++++ ++++++++++++++++ ++++++++++++++++\n";
cout << "+ + + + + +\n";
cout << "++++++ ++++++ + ++++++ + + +++++++++++\n";
cout << " + + + + + + + + \n";
cout << " + + + + + + + + \n";
cout << " + + + + + + + + \n";
cout << " + + + + + + + + \n";
cout << " + + + ++++++ + + + \n";
cout << " + + + + + + + +++++++++++\n";
cout << " + + + + + + + +\n";
cout << " ++++++ ++++++ ++++++ ++++++++++++++++\n";
cout << "\n\n";
cout << "++++++++++++++++ ++++++++++++++++ ++++++++++++++++\n";
cout << "+ + + + + +\n";
cout << "++++++ ++++++ + ++++++ + + +++++++++++\n";
cout << " + + + + + + + + \n";
cout << " + + + + + + + ++++++++ \n";
cout << " + + + + + + + + \n";
cout << " + + + + + + + ++++++++ \n";
cout << " + + + + + + + + \n";
cout << " + + + ++++++ + + +++++++++++\n";
cout << " + + + + + +\n";
cout << " ++++++ ++++++++++++++++ ++++++++++++++++\n";
C.exit = 1;
while (C.exit == 1)
{
int x, y, win, player;
string xy[3][3];
string playerc;
MENU();
switch (C.menu) //A switch statement that chooses the math option
{
xy[1][1]=" ";
xy[1][2]=" ";
xy[1][3]=" ";
xy[2][1]=" ";
xy[2][2]=" ";
xy[2][3]=" ";
xy[3][1]=" ";
xy[3][2]=" ";
xy[3][3]=" ";
case 0:
EXIT();
cin.get();
C.exit = 0;
break;
case 1:
cout << "What part of \"Not Yet Functional\" do you not understand?\n";
system("pause");
main();
break;
case 2:
clrscr();
cout << "\t\tInstructions\n";
cout << "Player 1 is X's, while Player 2 is O's\n";
cout << "Player 1 goes first. The object of this game is to get three of your sign\n";
cout << "in a row, whether it be vertically, horizontally, or diagonally.\n\n";
system("pause");
cout << "\t\tTIC-TAC-TOE\n";
cout << "\t______Two Player Game______\n\n";
cout << "\t\t 1 2 3\n\n";
cout << "\t\t | | \n";
cout << "\t\tA(1) | | \n";
cout << "\t\t _____|_____|_____\n";
cout << "\t\t | | \n";
cout << "\t\tB(2) | | \n";
cout << "\t\t _____|_____|_____\n";
cout << "\t\t | | \n";
cout << "\t\tC(3) | | \n";
cout << "\t\t | | \n\n";
win = 1;
player = 1;
while (win==1)
{
while (player==1)
{
playerc = "x";
cout << "Player 1, enter the number of the row you wish to move to: ";
cin >> x;
cout << "Now enter the number of the column you wish to move to: ";
cin >> y;
xy[x][y]=playerc;
system("pause");
cout << "\t\t 1 2 3\n\n";
cout << "\t\t | | \n";
cout << "\t\tA(1) "<<xy[1][1]<<" | "<<xy[1][2]<<" | "<<xy[1][3]<<" \n";
cout << "\t\t _____|_____|_____\n";
cout << "\t\t | | \n";
cout << "\t\tB(2) "<<xy[2][1]<<" | "<<xy[2][2]<<" | "<<xy[2][3]<<" \n";
cout << "\t\t _____|_____|_____\n";
cout << "\t\t | | \n";
cout << "\t\tC(3) "<<xy[3][1]<<" | "<<xy[3][2]<<" | "<<xy[3][3]<<" \n";
cout << "\t\t | | \n\n";
cin.get();
if (xy[1][1]==playerc)
{
if (xy[1][2]==playerc)
{
if (xy[1][3]==playerc)
{
if (playerc=="x")
{
win = 2;
}
else if (playerc=="o")
{
win = 3;
}
else
{
win = 1;
}
}
else
{
win = 1;
}
}
else if (xy[2][1]==playerc)
{
if (xy[3][1]==playerc)
{
if (playerc=="x")
{
win = 2;
}
else if (playerc=="o")
{
win = 3;
}
else
{
win = 1;
}
}
else
{
win = 1;
}
}
else if (xy[2][2]==playerc)
{
if (xy[3][3]==playerc)
{
if (playerc=="x")
{
win = 2;
}
else if (playerc=="o")
{
win = 3;
}
else
{
win = 1;
}
}
else
{
win = 1;
}
}
else
{
win = 1;
}
}
else if (xy[2][1]==playerc)
{
if (xy[2][2]==playerc)
{
if (xy[2][3]==playerc)
{
if (playerc=="x")
{
win = 2;
}
else if (playerc=="o")
{
win = 3;
}
else
{
win = 1;
}
}
else
{
win = 1;
}
}
else
{
win = 1;
}
}
else if (xy[3][1]==playerc)
{
if (xy[3][2]==playerc)
{
if (xy[3][3]==playerc)
{
if (playerc=="x")
{
win = 2;
}
else if (playerc=="o")
{
win = 3;
}
else
{
win = 1;
}
}
else
{
win = 1;
}
}
else if (xy[2][2]==playerc)
{
if (xy[1][3]==playerc)
{
if (playerc=="x")
{
win = 2;
}
else if (playerc=="o")
{
win = 3;
}
else
{
win = 1;
}
}
else
{
win = 1;
}
}
}
switch (win)
{
case 1:
player = 2;
break;
case 2:
cout << "Congrats Player 1, you have won!";
RorQ();
break;
default:
player = 2;
break;
}
}
while (player==2)
{
playerc = "o";
cout << "Player 2, enter the number of the row you wish to move to: ";
cin >> x;
cout << "Now enter the number of the column you wish to move to: ";
cin >> y;
xy[x][y]="o";
system("pause");
cout << "\t\t 1 2 3\n\n";
cout << "\t\t | | \n";
cout << "\t\tA(1) "<<xy[1][1]<<" | "<<xy[1][2]<<" | "<<xy[1][3]<<" \n";
cout << "\t\t _____|_____|_____\n";
cout << "\t\t | | \n";
cout << "\t\tB(2) "<<xy[2][1]<<" | "<<xy[2][2]<<" | "<<xy[2][3]<<" \n";
cout << "\t\t _____|_____|_____\n";
cout << "\t\t | | \n";
cout << "\t\tC(3) "<<xy[3][1]<<" | "<<xy[3][2]<<" | "<<xy[3][3]<<" \n";
cout << "\t\t | | \n\n";
if (xy[1][2]==playerc)
{
if (xy[1][3]==playerc)
{
if (playerc=="x")
{
win = 2;
}
else if (playerc=="o")
{
win = 3;
}
else
{
win = 1;
}
}
else
{
win = 1;
}
}
else if (xy[2][1]==playerc)
{
if (xy[3][1]==playerc)
{
if (playerc=="x")
{
win = 2;
}
else if (playerc=="o")
{
win = 3;
}
else
{
win = 1;
}
}
else
{
win = 1;
}
}
else if (xy[2][2]==playerc)
{
if (xy[3][3]==playerc)
{
if (playerc=="x")
{
win = 2;
}
else if (playerc=="o")
{
win = 3;
}
else
{
win = 1;
}
}
else
{
win = 1;
}
}
else
{
win = 1;
}
if (xy[2][1]==playerc)
{
if (xy[2][2]==playerc)
{
if (xy[2][3]==playerc)
{
if (playerc=="x")
{
win = 2;
}
else if (playerc=="o")
{
win = 3;
}
else
{
win = 1;
}
}
else
{
win = 1;
}
}
else
{
win = 1;
}
}
else if (xy[3][1]==playerc)
{
if (xy[3][2]==playerc)
{
if (xy[3][3]==playerc)
{
if (playerc=="x")
{
win = 2;
}
else if (playerc=="o")
{
win = 3;
}
else
{
win = 1;
}
}
else
{
win = 1;
}
}
else if (xy[2][2]==playerc)
{
if (xy[1][3]==playerc)
{
if (playerc=="x")
{
win = 2;
}
else if (playerc=="o")
{
win = 3;
}
else
{
win = 1;
}
}
else
{
win = 1;
}
}
}
switch (win)
{
case 1:
player = 1;
break;
case 2:
cout << "Congrats Player 2, you have won!";
RorQ();
break;
default:
player = 1;
break;
}
}
break;
case 3:
cout << "\t\tTic-Tac-Toe\n";
cout << "\t\tBy Michael Kylman\n\n";
cout << "Well, so far this game has no substance at all, it's just a menu!";
system("pause");
RorQ();
break;
default:
cout << "Sorry thats an incorrect choice!" <<"\n";
RorQ();
break;
}
clrscr();
}
cin.get();
return 0;
}
}
void MENU() //Gives user the choice of what math option to make
{
cout << "\n\n";
cout << "\t\tMENU\n";
cout << "0. EXIT GAME"<<"\n"; //Exits program
cout << "1. 1 Player Game(Not Yet Functional)" <<"\n"; //Adds two numbers
cout << "2. 2 Player Game"<<"\n"; //Subtracts two numbers
cout << "3. ABOUT" <<"\n"; //About the program
cout << "Enter the number of your selection>";
cin >> C.menu;
clrscr();
}
void EXIT()
{
cout << "Goodbye, Thanks for Playing!\n";
C.exit=0;
}
void RorQ() //Gives user the option to restart or quit
{
clrscr();
cout << "Press (r) to Return to the menu or (q) to Quit\n";
cout << ">";
cin >> C.rq[1];
cin.ignore();
if(C.rq[1] == 'r')
{
clrscr();
main();
}
else if(C.rq[1] == 'q')
{
EXIT();
}
else
{
cout << "Thats not a valid choice... Please rechoose" << "\n";
RorQ();
}
}
void clrscr() //Clears the screen
{
COORD coordScreen = { 0, 0 };
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsole, &csbi);
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten);
GetConsoleScreenBufferInfo(hConsole, &csbi);
FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
SetConsoleCursorPosition(hConsole, coordScreen);
}
Just a note, but I didn't write the clrscr() function, I took it, so I have no idea what it does... :-) anyway, there's the code, for those who don't wanna download it...