SlideShare a Scribd company logo
Please help with this. program must be written in C# .. All of the game logic must be written in a
seperate class using using an array that is passed in through a prperty that represents the game
board. The class needs to have methods to determine of someone won, or if there was a tie,
make sure all business logic is in a seperate class anot behind the UI..
***** These are the complete in instructions for the game assignment design
Create a Tic-Tac-Toe game that can be played by two players. The form will consist of a Tic-
Tac-Toe board in which the users’ click on to choose their space. As the game is being played
the Game Status section will tell whose turn it is. When someone wins or there is a tie, a message
will be displayed in the Game status section telling the users the status. When someone wins the
game the winning move needs to be indicated. There also needs to be a section that keeps track
of the number of wins for each player, and the number of ties. When the game is finished the
user may click the “Start Game” button to start a new game.
This program will consist of the main form and at least one class that will define the rules of the
game. This class will have an array that is passed in through a property that represents the game
board. The class will then have methods within it that determines if someone won, if there is a
tie, or if neither has occurred yet. Make sure all business logic is in a separate class and not
behind the UI.
EXTRA CREDIT (10 Points)
Create a computer player that can be played against. The computer player will need to be smart
enough to make a winning move or to block a winning move.
Solution
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace Tic_Tac_Toe
{
///
/// Description of MainForm.
///
public partial class MainForm : Form
{
Logic logicObj = new Logic();
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
int turn=1;
int click1=0,click2=0,click3=0,click4=0,click5=0,click6=0,click7=0,click8=0,click9=0;
int player1=0,player2=0;
void Button1Click(object sender, EventArgs e)
{
if(click1==0)
{
if(turn%2!=0)
{
button1.Text="X";
click1++;
}
else
{
button1.Text="O";
click1++;
}
turn++;
}
else
{
button1.Text=button1.Text;
}
display();
int a = logicObj.winLossFunc(button1.Text, button2.Text, button3.Text, button4.Text,
button5.Text, button6.Text, button7.Text, button8.Text, button9.Text);
if (a==1)
{
player1++;
player1score.Text = player1.ToString();
cleargame();
}
else if(a==2)
{
player2++;
player2score.Text = player2.ToString();
cleargame();
}
}
void Button2Click(object sender, EventArgs e)
{
if(click2==0)
{
if(turn%2!=0)
{
button2.Text="X";
click2++;
}
else
{
button2.Text="O";
click2++;
}
turn++;
}
else
{
button2.Text=button2.Text;
}
display();
int a = logicObj.winLossFunc(button1.Text, button2.Text, button3.Text, button4.Text,
button5.Text, button6.Text, button7.Text, button8.Text, button9.Text);
if (a == 1)
{
player1++;
player1score.Text = player1.ToString();
cleargame();
}
else if (a == 2)
{
player2++;
player2score.Text = player2.ToString();
cleargame();
}
}
void Button3Click(object sender, EventArgs e)
{
if(click3==0)
{
if(turn%2!=0)
{
button3.Text="X";
click3++;
}
else
{
button3.Text="O";
click3++;
}
turn++;
}
else
{
button3.Text=button3.Text;
}
display();
int a = logicObj.winLossFunc(button1.Text, button2.Text, button3.Text, button4.Text,
button5.Text, button6.Text, button7.Text, button8.Text, button9.Text);
if (a == 1)
{
player1++;
player1score.Text = player1.ToString();
cleargame();
}
else if (a == 2)
{
player2++;
player2score.Text = player2.ToString();
cleargame();
}
}
void Button4Click(object sender, EventArgs e)
{
if(click4==0)
{
if(turn%2!=0)
{
button4.Text="X";
click4++;
}
else
{
button4.Text="O";
click4++;
}
turn++;
}
else
{
button4.Text=button4.Text;
}
display();
int a = logicObj.winLossFunc(button1.Text, button2.Text, button3.Text, button4.Text,
button5.Text, button6.Text, button7.Text, button8.Text, button9.Text);
if (a == 1)
{
player1++;
player1score.Text = player1.ToString();
cleargame();
}
else if (a == 2)
{
player2++;
player2score.Text = player2.ToString();
cleargame();
}
}
void Button5Click(object sender, EventArgs e)
{
if(click5==0)
{
if(turn%2!=0)
{
button5.Text="X";
click5++;
}
else
{
button5.Text="O";
click5++;
}
turn++;
}
else
{
button5.Text=button5.Text;
}
display();
int a = logicObj.winLossFunc(button1.Text, button2.Text, button3.Text, button4.Text,
button5.Text, button6.Text, button7.Text, button8.Text, button9.Text);
if (a == 1)
{
player1++;
player1score.Text = player1.ToString();
cleargame();
}
else if (a == 2)
{
player2++;
player2score.Text = player2.ToString();
cleargame();
}
}
void Button6Click(object sender, EventArgs e)
{
if(click6==0)
{
if(turn%2!=0)
{
button6.Text="X";
click6++;
}
else
{
button6.Text="O";
click6++;
}
turn++;
}
else
{
button6.Text=button6.Text;
}
display();
int a = logicObj.winLossFunc(button1.Text, button2.Text, button3.Text, button4.Text,
button5.Text, button6.Text, button7.Text, button8.Text, button9.Text);
if (a == 1)
{
player1++;
player1score.Text = player1.ToString();
cleargame();
}
else if (a == 2)
{
player2++;
player2score.Text = player2.ToString();
cleargame();
}
}
void Button7Click(object sender, EventArgs e)
{
if(click7==0)
{
if(turn%2!=0)
{
button7.Text="X";
click7++;
}
else
{
button7.Text="O";
click7++;
}
turn++;
}
else
{
button7.Text=button7.Text;
}
display();
int a = logicObj.winLossFunc(button1.Text, button2.Text, button3.Text, button4.Text,
button5.Text, button6.Text, button7.Text, button8.Text, button9.Text);
if (a == 1)
{
player1++;
player1score.Text = player1.ToString();
cleargame();
}
else if (a == 2)
{
player2++;
player2score.Text = player2.ToString();
cleargame();
}
}
void Button8Click(object sender, EventArgs e)
{
if(click8==0)
{
if(turn%2!=0)
{
button8.Text="X";
click8++;
}
else
{
button8.Text="O";
click8++;
}
turn++;
}
else
{
button8.Text=button8.Text;
}
display();
int a = logicObj.winLossFunc(button1.Text, button2.Text, button3.Text, button4.Text,
button5.Text, button6.Text, button7.Text, button8.Text, button9.Text);
if (a == 1)
{
player1++;
player1score.Text = player1.ToString();
cleargame();
}
else if (a == 2)
{
player2++;
player2score.Text = player2.ToString();
cleargame();
}
}
void Button9Click(object sender, EventArgs e)
{
if(click9==0)
{
if(turn%2!=0)
{
button9.Text="X";
click9++;
}
else
{
button9.Text="O";
click9++;
}
turn++;
}
else
{
button9.Text=button9.Text;
}
display();
int a = logicObj.winLossFunc(button1.Text, button2.Text, button3.Text, button4.Text,
button5.Text, button6.Text, button7.Text, button8.Text, button9.Text);
if (a == 1)
{
player1++;
player1score.Text = player1.ToString();
cleargame();
}
else if (a == 2)
{
player2++;
player2score.Text = player2.ToString();
cleargame();
}
}
public void display()
{
if(turn%2!=0)
{
displayturn.Text="Player 1";
}
else
{
displayturn.Text="Player 2";
}
}
public void cleargame()
{
displayturn.Text="";
turn=1;
click1=0;click2=0;click3=0;click4=0;click5=0;click6=0;click7=0;click8=0;click9=0;
button1.Text="";
button2.Text="";
button3.Text="";
button4.Text="";
button5.Text="";
button6.Text="";
button7.Text="";
button8.Text="";
button9.Text="";
button1.BackColor=Color.Empty;
button1.ForeColor=Color.Black;
button1.UseVisualStyleBackColor=true;
button2.BackColor=Color.Empty;
button2.ForeColor=Color.Black;
button2.UseVisualStyleBackColor=true;
button3.BackColor=Color.Empty;
button3.ForeColor=Color.Black;
button3.UseVisualStyleBackColor=true;
button4.BackColor=Color.Empty;
button4.ForeColor=Color.Black;
button4.UseVisualStyleBackColor=true;
button5.BackColor=Color.Empty;
button5.ForeColor=Color.Black;
button5.UseVisualStyleBackColor=true;
button6.BackColor=Color.Empty;
button6.ForeColor=Color.Black;
button6.UseVisualStyleBackColor=true;
button7.BackColor=Color.Empty;
button7.ForeColor=Color.Black;
button7.UseVisualStyleBackColor=true;
button8.BackColor=Color.Empty;
button8.ForeColor=Color.Black;
button8.UseVisualStyleBackColor=true;
button9.BackColor=Color.Empty;
button9.ForeColor=Color.Black;
button9.UseVisualStyleBackColor=true;
}
void PlayagainClick(object sender, EventArgs e)
{
cleargame();
}
void ResetClick(object sender, EventArgs e)
{
player1score.Text="";
player2score.Text="";
player1=0;
player2=0;
cleargame();
}
}
}
Logic.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Tic_Tac_Toe
{
class Logic
{
public int winLossFunc(string b1, string b2, string b3, string b4, string b5, string b6, string b7,
string b8, string b9 )
{
if (b1 != "" && b2 != "" && b3 != "")
{
if (b1 == b2 && b1 == b3)
{
if (b1 == "X")
{
return 1;
}
else
{
return 2;
}
}
}
if (b4 != "" && b5 != "" && b6 != "")
{
if (b4 == b5 && b4 == b6)
{
if (b4 == "X")
{
return 1;
}
else
{
return 2;
}
}
}
if (b7 != "" && b8 != "" && b8 != "")
{
if (b7 == b8 && b7 == b8)
{
if (b7 == "X")
{
return 1;
}
else
{
return 2;
}
}
}
if (b1 != "" && b4 != "" && b7 != "")
{
if (b1 == b4 && b1 == b7)
{
if (b1 == "X")
{
return 1;
}
else
{
return 2;
}
}
}
if (b2 != "" && b5 != "" && b8 != "")
{
if (b2 == b5 && b2 == b8)
{
if (b2 == "X")
{
return 1;
}
else
{
return 2;
}
}
}
if (b3 != "" && b6 != "" && b8 != "")
{
if (b3 == b6 && b3 == b8)
{
if (b3 == "X")
{
return 1;
}
else
{
return 2;
}
}
}
if (b1 != "" && b5 != "" && b8 != "")
{
if (b1 == b5 && b1 == b8)
{
if (b1 == "X")
{
return 1;
}
else
{
return 2;
}
}
}
if (b3 != "" && b5 != "" && b7 != "")
{
if (b3 == b5 && b3 == b7)
{
if (b3 == "X")
{
return 1;
}
else
{
return 2;
}
}
}
return 0;
}
}
}

More Related Content

Similar to Please help with this. program must be written in C# .. All of the g.pdf

Java ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdfJava ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdf
atulkapoor33
 
package com.tictactoe; public class Main {public void play() {.pdf
package com.tictactoe; public class Main {public void play() {.pdfpackage com.tictactoe; public class Main {public void play() {.pdf
package com.tictactoe; public class Main {public void play() {.pdf
info430661
 
The main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfThe main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdf
asif1401
 
Tic tac toe c++ programing
Tic tac toe c++ programingTic tac toe c++ programing
Tic tac toe c++ programing
Krishna Agarwal
 
Sharable_Java_Python.pdf
Sharable_Java_Python.pdfSharable_Java_Python.pdf
Sharable_Java_Python.pdf
ICADCMLTPC
 
Need help writing the code for a basic java tic tac toe game Tic.pdf
Need help writing the code for a basic java tic tac toe game Tic.pdfNeed help writing the code for a basic java tic tac toe game Tic.pdf
Need help writing the code for a basic java tic tac toe game Tic.pdf
hainesburchett26321
 
WP7 HUB_XNA
WP7 HUB_XNAWP7 HUB_XNA
WP7 HUB_XNA
MICTT Palma
 
sports-teampackage.bluej#BlueJ package fileobjectbench.heig.docx
sports-teampackage.bluej#BlueJ package fileobjectbench.heig.docxsports-teampackage.bluej#BlueJ package fileobjectbench.heig.docx
sports-teampackage.bluej#BlueJ package fileobjectbench.heig.docx
whitneyleman54422
 
Tic tac toe on c++ project
Tic tac toe on c++ projectTic tac toe on c++ project
Tic tac toe on c++ project
Utkarsh Aggarwal
 
#include iostream#include fstream#include Opening.h.docx
#include iostream#include fstream#include Opening.h.docx#include iostream#include fstream#include Opening.h.docx
#include iostream#include fstream#include Opening.h.docx
adkinspaige22
 
Connect4.c2. Include the string.h header file3. Declare the foll.pdf
Connect4.c2. Include the string.h header file3. Declare the foll.pdfConnect4.c2. Include the string.h header file3. Declare the foll.pdf
Connect4.c2. Include the string.h header file3. Declare the foll.pdf
shakilaghani
 
Assignment 2 lab 3 python gpa calculator
Assignment 2 lab 3  python gpa calculatorAssignment 2 lab 3  python gpa calculator
Assignment 2 lab 3 python gpa calculator
Nagiob Doma
 
ma project
ma projectma project
ma projectAisu
 
Hello!This is Java assignment applet.Can someone help me writing.pdf
Hello!This is Java assignment applet.Can someone help me writing.pdfHello!This is Java assignment applet.Can someone help me writing.pdf
Hello!This is Java assignment applet.Can someone help me writing.pdf
jyothimuppasani1
 

Similar to Please help with this. program must be written in C# .. All of the g.pdf (15)

Java ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdfJava ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdf
 
package com.tictactoe; public class Main {public void play() {.pdf
package com.tictactoe; public class Main {public void play() {.pdfpackage com.tictactoe; public class Main {public void play() {.pdf
package com.tictactoe; public class Main {public void play() {.pdf
 
The main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfThe main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdf
 
Tic tac toe c++ programing
Tic tac toe c++ programingTic tac toe c++ programing
Tic tac toe c++ programing
 
Sharable_Java_Python.pdf
Sharable_Java_Python.pdfSharable_Java_Python.pdf
Sharable_Java_Python.pdf
 
Need help writing the code for a basic java tic tac toe game Tic.pdf
Need help writing the code for a basic java tic tac toe game Tic.pdfNeed help writing the code for a basic java tic tac toe game Tic.pdf
Need help writing the code for a basic java tic tac toe game Tic.pdf
 
WP7 HUB_XNA
WP7 HUB_XNAWP7 HUB_XNA
WP7 HUB_XNA
 
RandomGuessingGame
RandomGuessingGameRandomGuessingGame
RandomGuessingGame
 
sports-teampackage.bluej#BlueJ package fileobjectbench.heig.docx
sports-teampackage.bluej#BlueJ package fileobjectbench.heig.docxsports-teampackage.bluej#BlueJ package fileobjectbench.heig.docx
sports-teampackage.bluej#BlueJ package fileobjectbench.heig.docx
 
Tic tac toe on c++ project
Tic tac toe on c++ projectTic tac toe on c++ project
Tic tac toe on c++ project
 
#include iostream#include fstream#include Opening.h.docx
#include iostream#include fstream#include Opening.h.docx#include iostream#include fstream#include Opening.h.docx
#include iostream#include fstream#include Opening.h.docx
 
Connect4.c2. Include the string.h header file3. Declare the foll.pdf
Connect4.c2. Include the string.h header file3. Declare the foll.pdfConnect4.c2. Include the string.h header file3. Declare the foll.pdf
Connect4.c2. Include the string.h header file3. Declare the foll.pdf
 
Assignment 2 lab 3 python gpa calculator
Assignment 2 lab 3  python gpa calculatorAssignment 2 lab 3  python gpa calculator
Assignment 2 lab 3 python gpa calculator
 
ma project
ma projectma project
ma project
 
Hello!This is Java assignment applet.Can someone help me writing.pdf
Hello!This is Java assignment applet.Can someone help me writing.pdfHello!This is Java assignment applet.Can someone help me writing.pdf
Hello!This is Java assignment applet.Can someone help me writing.pdf
 

More from manjan6

An introduction and explanation of human factors and sociotechnical .pdf
An introduction and explanation of human factors and sociotechnical .pdfAn introduction and explanation of human factors and sociotechnical .pdf
An introduction and explanation of human factors and sociotechnical .pdf
manjan6
 
Astronomers were able to find a new planet in a far away solar system.pdf
Astronomers were able to find a new planet in a far away solar system.pdfAstronomers were able to find a new planet in a far away solar system.pdf
Astronomers were able to find a new planet in a far away solar system.pdf
manjan6
 
5. If we found AB+ blood at a crime scene and we knew one of our 5 s.pdf
5. If we found AB+ blood at a crime scene and we knew one of our 5 s.pdf5. If we found AB+ blood at a crime scene and we knew one of our 5 s.pdf
5. If we found AB+ blood at a crime scene and we knew one of our 5 s.pdf
manjan6
 
All of the following individuals are U.S. residents Kelly (27.pdf
All of the following individuals are U.S. residents Kelly (27.pdfAll of the following individuals are U.S. residents Kelly (27.pdf
All of the following individuals are U.S. residents Kelly (27.pdf
manjan6
 
Blossom Company had these transactions during the current period..pdf
Blossom Company had these transactions during the current period..pdfBlossom Company had these transactions during the current period..pdf
Blossom Company had these transactions during the current period..pdf
manjan6
 
Using the case study below, develop a written report of your market .pdf
Using the case study below, develop a written report of your market .pdfUsing the case study below, develop a written report of your market .pdf
Using the case study below, develop a written report of your market .pdf
manjan6
 
Which of the following is NOT a characteristic of a plasmid used as .pdf
Which of the following is NOT a characteristic of a plasmid used as .pdfWhich of the following is NOT a characteristic of a plasmid used as .pdf
Which of the following is NOT a characteristic of a plasmid used as .pdf
manjan6
 
What is the evolutionary significance of the amniotic egg Solut.pdf
What is the evolutionary significance of the amniotic egg  Solut.pdfWhat is the evolutionary significance of the amniotic egg  Solut.pdf
What is the evolutionary significance of the amniotic egg Solut.pdf
manjan6
 
What is the role of HTTP What types of objects are transmitted in H.pdf
What is the role of HTTP What types of objects are transmitted in H.pdfWhat is the role of HTTP What types of objects are transmitted in H.pdf
What is the role of HTTP What types of objects are transmitted in H.pdf
manjan6
 
What is the difference between a hash in perl and a hashtable in Jav.pdf
What is the difference between a hash in perl and a hashtable in Jav.pdfWhat is the difference between a hash in perl and a hashtable in Jav.pdf
What is the difference between a hash in perl and a hashtable in Jav.pdf
manjan6
 
What are the specific linkages among immune surveillance, clonal sel.pdf
What are the specific linkages among immune surveillance, clonal sel.pdfWhat are the specific linkages among immune surveillance, clonal sel.pdf
What are the specific linkages among immune surveillance, clonal sel.pdf
manjan6
 
True or False –Paraeducators provide direct or indirect instructio.pdf
True or False –Paraeducators provide direct or indirect instructio.pdfTrue or False –Paraeducators provide direct or indirect instructio.pdf
True or False –Paraeducators provide direct or indirect instructio.pdf
manjan6
 
The situation where the few who yell the loudest get heard Is ref.pdf
The situation where the few who yell the loudest get heard Is ref.pdfThe situation where the few who yell the loudest get heard Is ref.pdf
The situation where the few who yell the loudest get heard Is ref.pdf
manjan6
 
Templated Binary Tree implementing function help I need to im.pdf
Templated Binary Tree implementing function help I need to im.pdfTemplated Binary Tree implementing function help I need to im.pdf
Templated Binary Tree implementing function help I need to im.pdf
manjan6
 
State if you agree or disagree with the question and comments made b.pdf
State if you agree or disagree with the question and comments made b.pdfState if you agree or disagree with the question and comments made b.pdf
State if you agree or disagree with the question and comments made b.pdf
manjan6
 
A number of benefits that one might expect to see from using a datab.pdf
A number of benefits that one might expect to see from using a datab.pdfA number of benefits that one might expect to see from using a datab.pdf
A number of benefits that one might expect to see from using a datab.pdf
manjan6
 
QUESTION If you look at the code, youll see that we keep two list.pdf
QUESTION If you look at the code, youll see that we keep two list.pdfQUESTION If you look at the code, youll see that we keep two list.pdf
QUESTION If you look at the code, youll see that we keep two list.pdf
manjan6
 
Question 11 What is the volume of 17.0 grams of carbon dioxide gas if.pdf
Question 11 What is the volume of 17.0 grams of carbon dioxide gas if.pdfQuestion 11 What is the volume of 17.0 grams of carbon dioxide gas if.pdf
Question 11 What is the volume of 17.0 grams of carbon dioxide gas if.pdf
manjan6
 
Match the enzyme activity in DNA synthesis with its function. DNA po.pdf
Match the enzyme activity in DNA synthesis with its function.  DNA po.pdfMatch the enzyme activity in DNA synthesis with its function.  DNA po.pdf
Match the enzyme activity in DNA synthesis with its function. DNA po.pdf
manjan6
 
Introduction to Engineering ExperimentationSurface temperature con.pdf
Introduction to Engineering ExperimentationSurface temperature con.pdfIntroduction to Engineering ExperimentationSurface temperature con.pdf
Introduction to Engineering ExperimentationSurface temperature con.pdf
manjan6
 

More from manjan6 (20)

An introduction and explanation of human factors and sociotechnical .pdf
An introduction and explanation of human factors and sociotechnical .pdfAn introduction and explanation of human factors and sociotechnical .pdf
An introduction and explanation of human factors and sociotechnical .pdf
 
Astronomers were able to find a new planet in a far away solar system.pdf
Astronomers were able to find a new planet in a far away solar system.pdfAstronomers were able to find a new planet in a far away solar system.pdf
Astronomers were able to find a new planet in a far away solar system.pdf
 
5. If we found AB+ blood at a crime scene and we knew one of our 5 s.pdf
5. If we found AB+ blood at a crime scene and we knew one of our 5 s.pdf5. If we found AB+ blood at a crime scene and we knew one of our 5 s.pdf
5. If we found AB+ blood at a crime scene and we knew one of our 5 s.pdf
 
All of the following individuals are U.S. residents Kelly (27.pdf
All of the following individuals are U.S. residents Kelly (27.pdfAll of the following individuals are U.S. residents Kelly (27.pdf
All of the following individuals are U.S. residents Kelly (27.pdf
 
Blossom Company had these transactions during the current period..pdf
Blossom Company had these transactions during the current period..pdfBlossom Company had these transactions during the current period..pdf
Blossom Company had these transactions during the current period..pdf
 
Using the case study below, develop a written report of your market .pdf
Using the case study below, develop a written report of your market .pdfUsing the case study below, develop a written report of your market .pdf
Using the case study below, develop a written report of your market .pdf
 
Which of the following is NOT a characteristic of a plasmid used as .pdf
Which of the following is NOT a characteristic of a plasmid used as .pdfWhich of the following is NOT a characteristic of a plasmid used as .pdf
Which of the following is NOT a characteristic of a plasmid used as .pdf
 
What is the evolutionary significance of the amniotic egg Solut.pdf
What is the evolutionary significance of the amniotic egg  Solut.pdfWhat is the evolutionary significance of the amniotic egg  Solut.pdf
What is the evolutionary significance of the amniotic egg Solut.pdf
 
What is the role of HTTP What types of objects are transmitted in H.pdf
What is the role of HTTP What types of objects are transmitted in H.pdfWhat is the role of HTTP What types of objects are transmitted in H.pdf
What is the role of HTTP What types of objects are transmitted in H.pdf
 
What is the difference between a hash in perl and a hashtable in Jav.pdf
What is the difference between a hash in perl and a hashtable in Jav.pdfWhat is the difference between a hash in perl and a hashtable in Jav.pdf
What is the difference between a hash in perl and a hashtable in Jav.pdf
 
What are the specific linkages among immune surveillance, clonal sel.pdf
What are the specific linkages among immune surveillance, clonal sel.pdfWhat are the specific linkages among immune surveillance, clonal sel.pdf
What are the specific linkages among immune surveillance, clonal sel.pdf
 
True or False –Paraeducators provide direct or indirect instructio.pdf
True or False –Paraeducators provide direct or indirect instructio.pdfTrue or False –Paraeducators provide direct or indirect instructio.pdf
True or False –Paraeducators provide direct or indirect instructio.pdf
 
The situation where the few who yell the loudest get heard Is ref.pdf
The situation where the few who yell the loudest get heard Is ref.pdfThe situation where the few who yell the loudest get heard Is ref.pdf
The situation where the few who yell the loudest get heard Is ref.pdf
 
Templated Binary Tree implementing function help I need to im.pdf
Templated Binary Tree implementing function help I need to im.pdfTemplated Binary Tree implementing function help I need to im.pdf
Templated Binary Tree implementing function help I need to im.pdf
 
State if you agree or disagree with the question and comments made b.pdf
State if you agree or disagree with the question and comments made b.pdfState if you agree or disagree with the question and comments made b.pdf
State if you agree or disagree with the question and comments made b.pdf
 
A number of benefits that one might expect to see from using a datab.pdf
A number of benefits that one might expect to see from using a datab.pdfA number of benefits that one might expect to see from using a datab.pdf
A number of benefits that one might expect to see from using a datab.pdf
 
QUESTION If you look at the code, youll see that we keep two list.pdf
QUESTION If you look at the code, youll see that we keep two list.pdfQUESTION If you look at the code, youll see that we keep two list.pdf
QUESTION If you look at the code, youll see that we keep two list.pdf
 
Question 11 What is the volume of 17.0 grams of carbon dioxide gas if.pdf
Question 11 What is the volume of 17.0 grams of carbon dioxide gas if.pdfQuestion 11 What is the volume of 17.0 grams of carbon dioxide gas if.pdf
Question 11 What is the volume of 17.0 grams of carbon dioxide gas if.pdf
 
Match the enzyme activity in DNA synthesis with its function. DNA po.pdf
Match the enzyme activity in DNA synthesis with its function.  DNA po.pdfMatch the enzyme activity in DNA synthesis with its function.  DNA po.pdf
Match the enzyme activity in DNA synthesis with its function. DNA po.pdf
 
Introduction to Engineering ExperimentationSurface temperature con.pdf
Introduction to Engineering ExperimentationSurface temperature con.pdfIntroduction to Engineering ExperimentationSurface temperature con.pdf
Introduction to Engineering ExperimentationSurface temperature con.pdf
 

Recently uploaded

CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 

Recently uploaded (20)

CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 

Please help with this. program must be written in C# .. All of the g.pdf

  • 1. Please help with this. program must be written in C# .. All of the game logic must be written in a seperate class using using an array that is passed in through a prperty that represents the game board. The class needs to have methods to determine of someone won, or if there was a tie, make sure all business logic is in a seperate class anot behind the UI.. ***** These are the complete in instructions for the game assignment design Create a Tic-Tac-Toe game that can be played by two players. The form will consist of a Tic- Tac-Toe board in which the users’ click on to choose their space. As the game is being played the Game Status section will tell whose turn it is. When someone wins or there is a tie, a message will be displayed in the Game status section telling the users the status. When someone wins the game the winning move needs to be indicated. There also needs to be a section that keeps track of the number of wins for each player, and the number of ties. When the game is finished the user may click the “Start Game” button to start a new game. This program will consist of the main form and at least one class that will define the rules of the game. This class will have an array that is passed in through a property that represents the game board. The class will then have methods within it that determines if someone won, if there is a tie, or if neither has occurred yet. Make sure all business logic is in a separate class and not behind the UI. EXTRA CREDIT (10 Points) Create a computer player that can be played against. The computer player will need to be smart enough to make a winning move or to block a winning move. Solution using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; namespace Tic_Tac_Toe { /// /// Description of MainForm. /// public partial class MainForm : Form {
  • 2. Logic logicObj = new Logic(); public MainForm() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // // TODO: Add constructor code after the InitializeComponent() call. // } int turn=1; int click1=0,click2=0,click3=0,click4=0,click5=0,click6=0,click7=0,click8=0,click9=0; int player1=0,player2=0; void Button1Click(object sender, EventArgs e) { if(click1==0) { if(turn%2!=0) { button1.Text="X"; click1++; } else { button1.Text="O"; click1++; } turn++; } else { button1.Text=button1.Text; }
  • 3. display(); int a = logicObj.winLossFunc(button1.Text, button2.Text, button3.Text, button4.Text, button5.Text, button6.Text, button7.Text, button8.Text, button9.Text); if (a==1) { player1++; player1score.Text = player1.ToString(); cleargame(); } else if(a==2) { player2++; player2score.Text = player2.ToString(); cleargame(); } } void Button2Click(object sender, EventArgs e) { if(click2==0) { if(turn%2!=0) { button2.Text="X"; click2++; } else { button2.Text="O"; click2++; } turn++; } else
  • 4. { button2.Text=button2.Text; } display(); int a = logicObj.winLossFunc(button1.Text, button2.Text, button3.Text, button4.Text, button5.Text, button6.Text, button7.Text, button8.Text, button9.Text); if (a == 1) { player1++; player1score.Text = player1.ToString(); cleargame(); } else if (a == 2) { player2++; player2score.Text = player2.ToString(); cleargame(); } } void Button3Click(object sender, EventArgs e) { if(click3==0) { if(turn%2!=0) { button3.Text="X"; click3++; } else { button3.Text="O"; click3++; } turn++; } else
  • 5. { button3.Text=button3.Text; } display(); int a = logicObj.winLossFunc(button1.Text, button2.Text, button3.Text, button4.Text, button5.Text, button6.Text, button7.Text, button8.Text, button9.Text); if (a == 1) { player1++; player1score.Text = player1.ToString(); cleargame(); } else if (a == 2) { player2++; player2score.Text = player2.ToString(); cleargame(); } } void Button4Click(object sender, EventArgs e) { if(click4==0) { if(turn%2!=0) { button4.Text="X"; click4++; } else { button4.Text="O"; click4++; } turn++; } else
  • 6. { button4.Text=button4.Text; } display(); int a = logicObj.winLossFunc(button1.Text, button2.Text, button3.Text, button4.Text, button5.Text, button6.Text, button7.Text, button8.Text, button9.Text); if (a == 1) { player1++; player1score.Text = player1.ToString(); cleargame(); } else if (a == 2) { player2++; player2score.Text = player2.ToString(); cleargame(); } } void Button5Click(object sender, EventArgs e) { if(click5==0) { if(turn%2!=0) { button5.Text="X"; click5++; } else { button5.Text="O"; click5++; } turn++; } else
  • 7. { button5.Text=button5.Text; } display(); int a = logicObj.winLossFunc(button1.Text, button2.Text, button3.Text, button4.Text, button5.Text, button6.Text, button7.Text, button8.Text, button9.Text); if (a == 1) { player1++; player1score.Text = player1.ToString(); cleargame(); } else if (a == 2) { player2++; player2score.Text = player2.ToString(); cleargame(); } } void Button6Click(object sender, EventArgs e) { if(click6==0) { if(turn%2!=0) { button6.Text="X"; click6++; } else { button6.Text="O"; click6++; } turn++; } else
  • 8. { button6.Text=button6.Text; } display(); int a = logicObj.winLossFunc(button1.Text, button2.Text, button3.Text, button4.Text, button5.Text, button6.Text, button7.Text, button8.Text, button9.Text); if (a == 1) { player1++; player1score.Text = player1.ToString(); cleargame(); } else if (a == 2) { player2++; player2score.Text = player2.ToString(); cleargame(); } } void Button7Click(object sender, EventArgs e) { if(click7==0) { if(turn%2!=0) { button7.Text="X"; click7++; } else { button7.Text="O"; click7++; } turn++; } else
  • 9. { button7.Text=button7.Text; } display(); int a = logicObj.winLossFunc(button1.Text, button2.Text, button3.Text, button4.Text, button5.Text, button6.Text, button7.Text, button8.Text, button9.Text); if (a == 1) { player1++; player1score.Text = player1.ToString(); cleargame(); } else if (a == 2) { player2++; player2score.Text = player2.ToString(); cleargame(); } } void Button8Click(object sender, EventArgs e) { if(click8==0) { if(turn%2!=0) { button8.Text="X"; click8++; } else { button8.Text="O"; click8++; } turn++; } else
  • 10. { button8.Text=button8.Text; } display(); int a = logicObj.winLossFunc(button1.Text, button2.Text, button3.Text, button4.Text, button5.Text, button6.Text, button7.Text, button8.Text, button9.Text); if (a == 1) { player1++; player1score.Text = player1.ToString(); cleargame(); } else if (a == 2) { player2++; player2score.Text = player2.ToString(); cleargame(); } } void Button9Click(object sender, EventArgs e) { if(click9==0) { if(turn%2!=0) { button9.Text="X"; click9++; } else { button9.Text="O"; click9++; } turn++; } else
  • 11. { button9.Text=button9.Text; } display(); int a = logicObj.winLossFunc(button1.Text, button2.Text, button3.Text, button4.Text, button5.Text, button6.Text, button7.Text, button8.Text, button9.Text); if (a == 1) { player1++; player1score.Text = player1.ToString(); cleargame(); } else if (a == 2) { player2++; player2score.Text = player2.ToString(); cleargame(); } } public void display() { if(turn%2!=0) { displayturn.Text="Player 1"; } else { displayturn.Text="Player 2"; } } public void cleargame() { displayturn.Text=""; turn=1; click1=0;click2=0;click3=0;click4=0;click5=0;click6=0;click7=0;click8=0;click9=0;
  • 12. button1.Text=""; button2.Text=""; button3.Text=""; button4.Text=""; button5.Text=""; button6.Text=""; button7.Text=""; button8.Text=""; button9.Text=""; button1.BackColor=Color.Empty; button1.ForeColor=Color.Black; button1.UseVisualStyleBackColor=true; button2.BackColor=Color.Empty; button2.ForeColor=Color.Black; button2.UseVisualStyleBackColor=true; button3.BackColor=Color.Empty; button3.ForeColor=Color.Black; button3.UseVisualStyleBackColor=true; button4.BackColor=Color.Empty; button4.ForeColor=Color.Black; button4.UseVisualStyleBackColor=true; button5.BackColor=Color.Empty; button5.ForeColor=Color.Black; button5.UseVisualStyleBackColor=true; button6.BackColor=Color.Empty; button6.ForeColor=Color.Black; button6.UseVisualStyleBackColor=true; button7.BackColor=Color.Empty; button7.ForeColor=Color.Black; button7.UseVisualStyleBackColor=true; button8.BackColor=Color.Empty; button8.ForeColor=Color.Black; button8.UseVisualStyleBackColor=true; button9.BackColor=Color.Empty; button9.ForeColor=Color.Black; button9.UseVisualStyleBackColor=true;
  • 13. } void PlayagainClick(object sender, EventArgs e) { cleargame(); } void ResetClick(object sender, EventArgs e) { player1score.Text=""; player2score.Text=""; player1=0; player2=0; cleargame(); } } } Logic.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Tic_Tac_Toe { class Logic { public int winLossFunc(string b1, string b2, string b3, string b4, string b5, string b6, string b7, string b8, string b9 ) { if (b1 != "" && b2 != "" && b3 != "") { if (b1 == b2 && b1 == b3) { if (b1 == "X") { return 1;
  • 14. } else { return 2; } } } if (b4 != "" && b5 != "" && b6 != "") { if (b4 == b5 && b4 == b6) { if (b4 == "X") { return 1; } else { return 2; } } } if (b7 != "" && b8 != "" && b8 != "") { if (b7 == b8 && b7 == b8) { if (b7 == "X") { return 1; } else { return 2; } } }
  • 15. if (b1 != "" && b4 != "" && b7 != "") { if (b1 == b4 && b1 == b7) { if (b1 == "X") { return 1; } else { return 2; } } } if (b2 != "" && b5 != "" && b8 != "") { if (b2 == b5 && b2 == b8) { if (b2 == "X") { return 1; } else { return 2; } } } if (b3 != "" && b6 != "" && b8 != "") { if (b3 == b6 && b3 == b8) { if (b3 == "X") {
  • 16. return 1; } else { return 2; } } } if (b1 != "" && b5 != "" && b8 != "") { if (b1 == b5 && b1 == b8) { if (b1 == "X") { return 1; } else { return 2; } } } if (b3 != "" && b5 != "" && b7 != "") { if (b3 == b5 && b3 == b7) { if (b3 == "X") { return 1; } else { return 2;