Here is my source code: #include "stdafx.h"
#using
[Error: Irreparable invalid markup ('<mscorlib.dll>') in entry. Owner must fix manually. Raw contents below.]
<lj-cut text" I need help!"> <lj-cut>
Here is my source code: #include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
void GameBoard (void); /* function that sets-up game board display */
int location; /* Gameboard space: where player is marking */
int count; /* game counter, ends game after 9 turns */
char player; /* Player (either X or O) */
char location1=' '; /* Board space: First column, first space */
char location2=' '; /* Board space: Second column, first space */
char location3=' '; /* Board space: Third column, first space */
char location4=' '; /* Board space: First column, second space*/
char location5=' '; /* Board space: Second column, second space */
char location6=' '; /* Board space: Third column, second space */
char location7=' '; /* Board space: First column, third apace */
char location8=' '; /* Board space: Second Column, third space */
char location9=' '; /* Board space: Third column, third space */
char location0=' '; /* Allows user to exit game before compleation */
int selection;
int X;
int O;
int Player;
int _tmain()
{
GameBoard(); /* calls the gameboard */
printf("Which player are you (enter X or O) : ");
scanf("%c", &player);
printf("What space do you want to put your X or O in?");
scanf("%d", &location);
switch (location)
{
case 1:
location1=Player;
break;
case 2:
location2=Player;
break;
case 3:
location3=Player;
break;
case 4:
location4=Player;
break;
case 5:
location5=Player;
break;
case 6:
location6=Player;
break;
case 7:
location7=Player;
break;
case 8:
location8=Player;
break;
case 9:
location9=Player;
break;
}
{
count++;
while (count<=9); /* Sets game to loop 9 times, after 9 inputs the gameboard is filled and there should be a winner */
if (player=='X')
player='O';
else
player='X';
return 0;
}
}
void GameBoard(void)
{
printf("\n\n");
printf(" %c | %c | %c 1 | 2 | 3\n", location1, location2, location3);
printf(" --------- \n");
printf(" %c | %c | %c 4 | 5 | 6\n", location4, location5, location6);
printf(" --------- \n");
printf(" %c | %c | %c 7 | 8 | 9\n\n", location7, location8, location9);
}
<b>Here is the assignment:</b> Assignment #3 - Minimum Requirements:
Create a program which allows two players to play a game of Tic Tac Toe on the computer. It should work in the same way that you might play with a friend using a piece of paper and pencil. The gameboard is displayed, and each player is asked to input an X or an O. The player is then asked to enter a location for their X or O. The gameboard is then redisplayed, showing an X or O in the correct location.
The gameboard should look something like this (but, you can be more creative if you wish):
| | X
------------------
| X |
------------------
X | O | O
The game above was created by player X choosing locations 3, 5 and 7 during his/her turn. Player O chose locations 8 and 9.
1 2 3
4 5 6
7 8 9
Hint: You should be able to create the gameboard using printf statements that include 3 char placeholders and 2 vertical bars. For example,
printf(“ %c | %c | %c \n” , location1, location2, location3);
The variables: location1, loacation2 and location3, are character type variables that correspond to the first row on the gameboard. You will need 6 more to complete the gameboard.
The gameboard must not be allowed to display more than 9 times (because the board should be filled by then).
Deliverables:
Hard copy of the program source file. (60%)
Screen shots of the program in action. (30%)
Email copy of the program source file. (10%)
The usual standards must be met in regards to formatting, code structure and commenting. For full credit the program must also execute properly, it must use loop whenever appropriate.
If you accomplish the minimum requirements, as stated above, to a satisfactory level you will earn a maximum grade of 75%.
In order to add to your grade you should add one or more of the following features to your implementation.
• Allow the player to stop the game at any time by entering a location value of 0 (zero).
• Since players O and X take turns during the game, it is not really necessary to have the user enter ‘X’ or ‘O’, instead assume play starts with X and alternate back and forth. The players only need to enter the location they wish to use.
• Do not allow anyone to play on a space that is already taken. i.e. if X has already taken the center location, do not allow O to take it, or for X to play it again.
Extra Credit: (only accepted if the three additional features above are already included).
• Determine when a win has occurred and stop the game.
sorry for the long post, but I do need help. I'm not sure on how to end it, can someone help me?
</lj-cut>
Here is my source code: #include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
void GameBoard (void); /* function that sets-up game board display */
int location; /* Gameboard space: where player is marking */
int count; /* game counter, ends game after 9 turns */
char player; /* Player (either X or O) */
char location1=' '; /* Board space: First column, first space */
char location2=' '; /* Board space: Second column, first space */
char location3=' '; /* Board space: Third column, first space */
char location4=' '; /* Board space: First column, second space*/
char location5=' '; /* Board space: Second column, second space */
char location6=' '; /* Board space: Third column, second space */
char location7=' '; /* Board space: First column, third apace */
char location8=' '; /* Board space: Second Column, third space */
char location9=' '; /* Board space: Third column, third space */
char location0=' '; /* Allows user to exit game before compleation */
int selection;
int X;
int O;
int Player;
int _tmain()
{
GameBoard(); /* calls the gameboard */
printf("Which player are you (enter X or O) : ");
scanf("%c", &player);
printf("What space do you want to put your X or O in?");
scanf("%d", &location);
switch (location)
{
case 1:
location1=Player;
break;
case 2:
location2=Player;
break;
case 3:
location3=Player;
break;
case 4:
location4=Player;
break;
case 5:
location5=Player;
break;
case 6:
location6=Player;
break;
case 7:
location7=Player;
break;
case 8:
location8=Player;
break;
case 9:
location9=Player;
break;
}
{
count++;
while (count<=9); /* Sets game to loop 9 times, after 9 inputs the gameboard is filled and there should be a winner */
if (player=='X')
player='O';
else
player='X';
return 0;
}
}
void GameBoard(void)
{
printf("\n\n");
printf(" %c | %c | %c 1 | 2 | 3\n", location1, location2, location3);
printf(" --------- \n");
printf(" %c | %c | %c 4 | 5 | 6\n", location4, location5, location6);
printf(" --------- \n");
printf(" %c | %c | %c 7 | 8 | 9\n\n", location7, location8, location9);
}
<b>Here is the assignment:</b> Assignment #3 - Minimum Requirements:
Create a program which allows two players to play a game of Tic Tac Toe on the computer. It should work in the same way that you might play with a friend using a piece of paper and pencil. The gameboard is displayed, and each player is asked to input an X or an O. The player is then asked to enter a location for their X or O. The gameboard is then redisplayed, showing an X or O in the correct location.
The gameboard should look something like this (but, you can be more creative if you wish):
| | X
------------------
| X |
------------------
X | O | O
The game above was created by player X choosing locations 3, 5 and 7 during his/her turn. Player O chose locations 8 and 9.
1 2 3
4 5 6
7 8 9
Hint: You should be able to create the gameboard using printf statements that include 3 char placeholders and 2 vertical bars. For example,
printf(“ %c | %c | %c \n” , location1, location2, location3);
The variables: location1, loacation2 and location3, are character type variables that correspond to the first row on the gameboard. You will need 6 more to complete the gameboard.
The gameboard must not be allowed to display more than 9 times (because the board should be filled by then).
Deliverables:
Hard copy of the program source file. (60%)
Screen shots of the program in action. (30%)
Email copy of the program source file. (10%)
The usual standards must be met in regards to formatting, code structure and commenting. For full credit the program must also execute properly, it must use loop whenever appropriate.
If you accomplish the minimum requirements, as stated above, to a satisfactory level you will earn a maximum grade of 75%.
In order to add to your grade you should add one or more of the following features to your implementation.
• Allow the player to stop the game at any time by entering a location value of 0 (zero).
• Since players O and X take turns during the game, it is not really necessary to have the user enter ‘X’ or ‘O’, instead assume play starts with X and alternate back and forth. The players only need to enter the location they wish to use.
• Do not allow anyone to play on a space that is already taken. i.e. if X has already taken the center location, do not allow O to take it, or for X to play it again.
Extra Credit: (only accepted if the three additional features above are already included).
• Determine when a win has occurred and stop the game.
sorry for the long post, but I do need help. I'm not sure on how to end it, can someone help me?
</lj-cut>
