Skip to main content

Tic Tac Toe

Assalamualaikum sahabat,
kali ini kita akan bermain main dengan game tic tac toe, tau dong atau di indonesia lebih di kenal dengan nama XOX, nah langsung aja ya kita akan membuat program sederhana dari game ini ,seperti biasa kita menggunakan visual c# 2010
ok ini dia program nya


PRAKTIKUM PEMOGRAMAN


/*
 * Created by SharpDevelop.
 * User: mhs
 * Date: 4/30/2014
 * Time: 1:48 PM
 *
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.Media;

namespace Tic_Tac_Toe
{
     /// <summary>
     /// Description of MainForm.
     /// </summary>
     public partial class MainForm : Form
     {
           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;
          
           public void display()
           {
                if(twoPlayer.Checked == true)
                {
                     if(turn%2!=0)
                     {
                           disTurn.Text="Player 1 Turn!";
                     }
                     else
                     {
                           disTurn.Text="Player 2 Turn!";
                     }
                }
                else if(vsCom.Checked == true)
                {
                     if(turn%2!=0)
                     {
                           disTurn.Text="Player 1 Turn!";
                     }
                     else
                     {
                           disTurn.Text="Computer Turn!";
                     }
                }
           }
          
          
          
           private void ComPlay()
        {
            if (button1.Text == "O" && button2.Text == "O")
            {
                if (button3.Text == "")
                {
                    button3.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button2.Text == "O" && button3.Text == "O")
            {
                if (button1.Text == "")
                {
                    button1.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button1.Text == "O" && button3.Text == "O")
            {
                if (button2.Text == "")
                {
                    button2.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button1.Text == "O" && button7.Text == "O")
            {
                if (button4.Text == "")
                {
                    button4.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button1.Text == "O" && button4.Text == "O")
            {
                if (button7.Text == "")
                {
                    button7.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button4.Text == "O" && button7.Text == "O")
            {
                if (button1.Text == "")
                {
                    button1.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button1.Text == "O" && button5.Text == "O")
            {
                if (button9.Text == "")
                {
                    button9.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button5.Text == "O" && button9.Text == "O")
            {
                if (button1.Text == "")
                {
                    button1.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button1.Text == "O" && button9.Text == "O")
            {
                if (button5.Text == "")
                {
                    button5.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button2.Text == "O" && button5.Text == "O")
            {
                if (button8.Text == "")
                {
                    button8.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button2.Text == "O" && button8.Text == "O")
            {
                if (button5.Text == "")
                {
                    button5.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button5.Text == "O" && button8.Text == "O")
            {
                if (button2.Text == "")
                {
                    button2.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button3.Text == "O" && button6.Text == "O")
            {
                if (button9.Text == "")
                {
                    button9.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button5.Text == "O" && button8.Text == "O")
            {
                if (button2.Text == "")
                {
                    button2.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button3.Text == "O" && button9.Text == "O")
            {
                if (button6.Text == "")
                {
                    button6.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button6.Text == "O" && button9.Text == "O")
            {
                if (button3.Text == "")
                {
                    button3.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button4.Text == "O" && button5.Text == "O")
            {
                if (button4.Text == "")
                {
                    button6.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button4.Text == "O" && button6.Text == "O")
            {
                if (button5.Text == "")
                {
                    button5.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button5.Text == "O" && button6.Text == "O")
            {
                if (button4.Text == "")
                {
                    button4.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button7.Text == "O" && button9.Text == "O")
            {
                if (button8.Text == "")
                {
                    button8.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button8.Text == "O" && button9.Text == "O")
            {
                if (button7.Text == "")
                {
                    button7.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button7.Text == "O" && button8.Text == "O")
            {
                if (button9.Text == "")
                {
                    button9.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button3.Text == "O" && button5.Text == "O")
            {
                if (button7.Text == "")
                {
                    button7.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button5.Text == "O" && button7.Text == "O")
            {
                if (button3.Text == "")
                {
                    button3.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button3.Text == "O" && button7.Text == "O")
            {
                if (button5.Text == "")
                {
                    button5.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button1.Text == "X" && button2.Text == "X")
            {
                if (button3.Text == "")
                {
                    button3.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button2.Text == "X" && button3.Text == "X")
            {
                if (button1.Text == "")
                {
                    button1.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button1.Text == "X" && button3.Text == "X")
            {
                if (button2.Text == "")
                {
                    button2.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button1.Text == "X" && button4.Text == "X")
            {
                if (button7.Text == "")
                {
                    button7.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button1.Text == "X" && button7.Text == "X")
            {
                if (button4.Text == "")
                {
                    button4.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button4.Text == "X" && button7.Text == "X")
            {
                if (button1.Text == "")
                {
                    button1.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button1.Text == "X" && button9.Text == "X")
            {
                if (button5.Text == "")
                {
                    button5.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button1.Text == "X" && button5.Text == "X")
            {
                if (button9.Text == "")
                {
                    button9.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button5.Text == "X" && button9.Text == "X")
            {
                if (button5.Text == "")
                {
                    button1.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button4.Text == "X" && button5.Text == "X")
            {
                if (button6.Text == "")
                {
                    button6.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button4.Text == "X" && button6.Text == "X")
            {
                if (button5.Text == "")
                {
                    button5.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button5.Text == "X" && button6.Text == "X")
            {
                if (button4.Text == "")
                {
                    button4.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button7.Text == "X" && button9.Text == "X")
            {
                if (button8.Text == "")
                {
                    button8.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button7.Text == "X" && button8.Text == "X")
            {
                if (button9.Text == "")
                {
                    button9.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button8.Text == "X" && button9.Text == "X")
            {
                if (button7.Text == "")
                {
                    button7.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button2.Text == "X" && button5.Text == "X")
            {
                if (button8.Text == "")
                {
                    button8.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button3.Text == "X" && button6.Text == "X")
            {
                if (button9.Text == "")
                {
                    button9.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button5.Text == "X" && button7.Text == "X")
            {
                if (button3.Text == "")
                {
                    button3.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button2.Text == "X" && button7.Text == "X")
            {
                if (button5.Text == "")
                {
                    button5.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button3.Text == "X" && button9.Text == "X")
            {
                if (button6.Text == "")
                {
                    button6.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button6.Text == "X" && button9.Text == "X")
            {
                if (button3.Text == "")
                {
                    button3.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button3.Text == "X" && button9.Text == "X")
            {
                if (button6.Text == "")
                {
                    button6.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button5.Text == "X" && button8.Text == "X")
            {
                if (button2.Text == "")
                {
                    button2.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button3.Text == "X" && button5.Text == "X")
            {
                if (button7.Text == "")
                {
                    button7.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button5.Text == "X" && button7.Text == "X")
            {
                if (button3.Text == "")
                {
                    button3.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button3.Text == "X" && button7.Text == "X")
            {
                if (button5.Text == "")
                {
                    button5.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button5.Text == "")
            {
                button5.Text = "O";
                checkit();
                return;
            }

            if (button1.Text == "X" && button9.Text == "X" && button5.Text == "O")
            {
                if (button2.Text == "")
                {
                    button2.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button3.Text == "X" && button7.Text == "X" && button5.Text == "O")
            {
                if (button2.Text == "")
                {
                    button2.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button5.Text == "O" && button2.Text == "X")
            {
                if (button3.Text == "")
                {
                    button3.Text = "O";
                    checkit();
                    return;
                }
            }

            if (button5.Text == "O" && button8.Text == "X")
            {
                if (button9.Text == "")
                {
                    button9.Text = "O";
                    checkit();
                    return;
                }
            }

            // last options if none of the above are false
            if (button1.Text == "")
            {
                button1.Text = "O";
                checkit();
                return;
            }

            if (button3.Text == "")
            {
                button3.Text ="O";
                checkit();
                return;
            }

            if (button9.Text == "")
            {
                button9.Text = "O";
                checkit();
                return;
            }

            if (button6.Text == "")
            {
                button6.Text = "O";
                checkit();
                return;
            }
           }
          
           public void checkit()
           {
                if (button1.Text!="" && button2.Text!="" && button3.Text!="" && button4.Text!="" && button5.Text!="" && button6.Text!="" &&
                    button7.Text!="" && button8.Text!="" && button9.Text!="")
            {
                MessageBox.Show("Game Draw!");
                cleargame();
            }
               
                else if(button1.Text!="" && button2.Text!="" && button3.Text!="")
                {
                     if(button1.Text==button2.Text && button1.Text==button3.Text)
                     {
                          
                           button1.BackColor=Color.Green;
                           button1.ForeColor=Color.White;
                           button2.BackColor=Color.Green;
                           button2.ForeColor=Color.White;
                           button3.BackColor=Color.Green;
                           button3.ForeColor=Color.White;
                          
                           if(twoPlayer.Checked == true)
                           {
                                if(button1.Text=="X")
                                {
                                     MessageBox.Show("Player 1 Wins!");
                                     player1++;
                                     P1score.Text=player1.ToString();
                                }
                          
                                else
                                {
                                     MessageBox.Show("Player 2 Wins!");
                                     player2++;
                                     P2score.Text=player2.ToString();
                                }
                           }
                           else if(vsCom.Checked == true)
                           {
                                if(button1.Text=="X")
                                {
                                     MessageBox.Show("Player 1 Wins!");
                                     player1++;
                                      P1score.Text=player1.ToString();
                                }
                          
                                else
                                {
                                     MessageBox.Show("Computer Wins!");
                                     player2++;
                                     P2score.Text=player2.ToString();
                                }
                           }
                    
                           cleargame();
                     }
                }
                    
                if(button4.Text!="" && button5.Text!="" && button6.Text!="")
                {
                     if(button4.Text==button5.Text && button4.Text==button6.Text)
                     {
                          
                           button4.BackColor=Color.Green;
                           button4.ForeColor=Color.White;
                           button5.BackColor=Color.Green;
                           button5.ForeColor=Color.White;
                           button6.BackColor=Color.Green;
                           button6.ForeColor=Color.White;
                          
                           if(twoPlayer.Checked == true)
                           {
                                if(button4.Text=="X")
                                {
                                     MessageBox.Show("Player 1 Wins!");
                                     player1++;
                                     P1score.Text=player1.ToString();
                                }
                               
                                else
                                {
                                     MessageBox.Show("Player 2 Wins!");
                                     player2++;
                                     P2score.Text=player2.ToString();
                                }
                           }
                           else if(vsCom.Checked == true)
                           {
                                if(button4.Text=="X")
                                {
                                     MessageBox.Show("Player 1 Wins!");
                                     player1++;
                                     P1score.Text=player1.ToString();
                                }
                               
                                else
                                {
                                     MessageBox.Show("Computer Wins!");
                                     player2++;
                                     P2score.Text=player2.ToString();
                                }
                           }
                           cleargame();
                     }
                }
          
                if(button7.Text!="" && button8.Text!="" && button9.Text!="")
                {
                     if(button7.Text==button8.Text && button7.Text==button9.Text)
                     {
                          
                           button7.BackColor=Color.Green;
                           button7.ForeColor=Color.White;
                           button8.BackColor=Color.Green;
                           button8.ForeColor=Color.White;
                           button9.BackColor=Color.Green;
                           button9.ForeColor=Color.White;
                          
                           if(twoPlayer.Checked == true)
                           {
                                if(button7.Text=="X")
                                {
                                     MessageBox.Show("Player 1 Wins!");
                                     player1++;
                                     P1score.Text=player1.ToString();
                                }
                               
                                else
                                {
                                     MessageBox.Show("Player 2 Wins!");
                                     player2++;
                                     P2score.Text=player2.ToString();
                                }
                           }
                           else if(vsCom.Checked == true)
                           {
                                if(button7.Text=="X")
                                {
                                     MessageBox.Show("Player 1 Wins!");
                                     player1++;
                                     P1score.Text=player1.ToString();
                                }
                               
                                else
                                {
                                     MessageBox.Show("Computer Wins!");
                                     player2++;
                                     P2score.Text=player2.ToString();
                                }
                           }
                           cleargame();
                     }
                }
               
                if(button1.Text!="" && button5.Text!="" && button9.Text!="")
                {
                     if(button1.Text==button5.Text && button1.Text==button9.Text)
                     {
                          
                           button1.BackColor=Color.Green;
                           button1.ForeColor=Color.White;
                           button5.BackColor=Color.Green;
                           button5.ForeColor=Color.White;
                           button9.BackColor=Color.Green;
                           button9.ForeColor=Color.White;
                          
                           if(twoPlayer.Checked == true)
                           {
                                if(button1.Text=="X")
                                {
                                     MessageBox.Show("Player 1 Wins!");
                                     player1++;
                                     P1score.Text=player1.ToString();
                                }
                               
                                else
                                {
                                     MessageBox.Show("Player 2 Wins!");
                                     player2++;
                                     P2score.Text=player2.ToString();
                                }
                           }
                           else if(vsCom.Checked == true)
                           {
                                if(button1.Text=="X")
                                {
                                     MessageBox.Show("Player 1 Wins!");
                                     player1++;
                                     P1score.Text=player1.ToString();
                                }
                               
                                else
                                {
                                     MessageBox.Show("Computer Wins!");
                                     player2++;
                                     P2score.Text=player2.ToString();
                                }
                           }
                           cleargame();
                     }
                }
               
                if(button1.Text!="" && button4.Text!="" && button7.Text!="")
                {
                     if(button1.Text==button4.Text && button1.Text==button7.Text)
                     {
                          
                           button1.BackColor=Color.Green;
                           button1.ForeColor=Color.White;
                           button4.BackColor=Color.Green;
                           button4.ForeColor=Color.White;
                           button7.BackColor=Color.Green;
                           button7.ForeColor=Color.White;
                          
                           if(twoPlayer.Checked == true)
                           {
                                if(button1.Text=="X")
                                {
                                     MessageBox.Show("Player 1 Wins!");
                                     player1++;
                                     P1score.Text=player1.ToString();
                                }
                               
                                else
                                {
                                     MessageBox.Show("Player 2 Wins!");
                                     player2++;
                                     P2score.Text=player2.ToString();
                                }
                           }
                           else if(vsCom.Checked == true)
                           {
                                if(button1.Text=="X")
                                {
                                     MessageBox.Show("Player 1 Wins!");
                                     player1++;
                                     P1score.Text=player1.ToString();
                                }
                               
                                else
                                {
                                     MessageBox.Show("Computer Wins!");
                                     player2++;
                                     P2score.Text=player2.ToString();
                                }
                           }
                           cleargame();
                     }
                }
               
                if(button2.Text!="" && button5.Text!="" && button8.Text!="")
                {
                     if(button2.Text==button5.Text && button2.Text==button8.Text)
                     {
                          
                           button2.BackColor=Color.Green;
                           button2.ForeColor=Color.White;
                           button5.BackColor=Color.Green;
                           button5.ForeColor=Color.White;
                           button8.BackColor=Color.Green;
                           button8.ForeColor=Color.White;
                          
                           if(twoPlayer.Checked == true)
                           {
                                if(button2.Text=="X")
                                {
                                     MessageBox.Show("Player 1 Wins!");
                                     player1++;
                                     P1score.Text=player1.ToString();
                                }
                               
                                else
                                {
                                     MessageBox.Show("Player 2 Wins!");
                                     player2++;
                                     P2score.Text=player2.ToString();
                                }
                           }
                           else if(vsCom.Checked == true)
                           {
                                if(button2.Text=="X")
                                {
                                     MessageBox.Show("Player 1 Wins!");
                                     player1++;
                                     P1score.Text=player1.ToString();
                                }
                               
                                else
                                {
                                     MessageBox.Show("Computer Wins!");
                                     player2++;
                                     P2score.Text=player2.ToString();
                                }
                           }
                           cleargame();
                     }
                }
               
                if(button3.Text!="" && button6.Text!="" && button9.Text!="")
                {
                     if(button3.Text==button6.Text && button3.Text==button9.Text)
                     {
                          
                           button3.BackColor=Color.Green;
                           button3.ForeColor=Color.White;
                           button6.BackColor=Color.Green;
                           button6.ForeColor=Color.White;
                           button9.BackColor=Color.Green;
                           button9.ForeColor=Color.White;
                          
                           if(twoPlayer.Checked == true)
                           {
                                if(button3.Text=="X")
                                {
                                     MessageBox.Show("Player 1 Wins!");
                                     player1++;
                                     P1score.Text=player1.ToString();
                                }
                               
                                else
                                {
                                     MessageBox.Show("Player 2 Wins!");
                                     player2++;
                                     P2score.Text=player2.ToString();
                                }
                           }
                           else if(vsCom.Checked == true)
                           {
                                if(button3.Text=="X")
                                {
                                     MessageBox.Show("Player 1 Wins!");
                                     player1++;
                                     P1score.Text=player1.ToString();
                                }
                               
                                else
                                {
                                     MessageBox.Show("Computer Wins!");
                                     player2++;
                                     P2score.Text=player2.ToString();
                                }
                           }
                           cleargame();
                     }
                }
               
                if(button3.Text!="" && button5.Text!="" && button7.Text!="")
                {
                     if(button3.Text==button5.Text && button3.Text==button7.Text)
                     {
                          
                           button3.BackColor=Color.Green;
                           button3.ForeColor=Color.White;
                           button5.BackColor=Color.Green;
                           button5.ForeColor=Color.White;
                           button7.BackColor=Color.Green;
                           button7.ForeColor=Color.White;
                          
                           if(twoPlayer.Checked == true)
                           {
                                if(button3.Text=="X")
                                {
                                     MessageBox.Show("Player 1 Wins!");
                                     player1++;
                                     P1score.Text=player1.ToString();
                                }
                               
                                else
                                {
                                     MessageBox.Show("Player 2 Wins!");
                                     player2++;
                                     P2score.Text=player2.ToString();
                                }
                           }
                           else if(vsCom.Checked == true)
                           {
                                if(button3.Text=="X")
                                {
                                     MessageBox.Show("Player 1 Wins!");
                                     player1++;
                                     P1score.Text=player1.ToString();
                                }
                               
                                else
                                {
                                     MessageBox.Show("Computer Wins!");
                                     player2++;
                                     P2score.Text=player2.ToString();
                                }
                           }
                           cleargame();
                     }   
                }   
           }
          
     public void cleargame()
    {
      disTurn.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 Button1Click(object sender, EventArgs e)
           {
               
                if(twoPlayer.Checked == true)
                {
                     if(click1==0)
                     {
                           if(turn%2!=0)
                           {
                                button1.Text="X";
                           }
                           else
                           {
                                button1.Text="O";
                           }
                           turn++;
                           click1++;
                     }
                     else
                     {
                           MessageBox.Show("The button is already chosen!!!");
                     }
                }
                else if(vsCom.Checked == true)
                {
                     ButtonClick(ref button1);
                }
                else
            {
                MessageBox.Show("silahkan pilih  game mode!!!");
            }
                display();
                checkit();
           }
          
           void Button2Click(object sender, EventArgs e)
           {
               
                if(twoPlayer.Checked == true)
                {
                     if(click2==0)
                     {
                           if(turn%2!=0)
                           {
                                button2.Text="X";
                           }
                           else
                           {
                                button2.Text="O";
                          }
                           turn++;
                           click2++;
                     }
                     else
                     {
                           MessageBox.Show("The button is already chosen!!!");
                     }
                }
                else if(vsCom.Checked == true)
                {
                     ButtonClick(ref button2);
                }
                else
            {
                MessageBox.Show("Please chose game mode!!!");
            }
                display();
                checkit();
           }
          
           void Button3Click(object sender, EventArgs e)
           {
               
                if(twoPlayer.Checked == true)
                {
                     if(click3==0)
                     {
                           if(turn%2!=0)
                           {
                                button3.Text="X";
                           }
                          else
                           {
                                button3.Text="O";
                           }
                           turn++;
                           click3++;
                     }   
                     else
                     {
                           MessageBox.Show("The button is already chosen!!!");
                     }
                }
                else if(vsCom.Checked == true)
                {
                     ButtonClick(ref button3);
                }
                else
            {
                MessageBox.Show("Please chose game mode!!!");
            }
                display();
                checkit();
           }
          
           void Button4Click(object sender, EventArgs e)
           {
               
                if(twoPlayer.Checked == true)
                {
                     if(click4==0)
                     {
                           if(turn%2!=0)
                           {
                                button4.Text="X";
                           }
                           else
                           {
                                button4.Text="O";
                           }
                           turn++;
                           click4++;
                     }
                     else
                     {
                           MessageBox.Show("The button is already chosen!!!");
                     }
                }
                else if(vsCom.Checked == true)
                {
                      ButtonClick(ref button4);
                }
                else
            {
                MessageBox.Show("Please chose game mode!!!");
            }
                display();
                checkit();
           }
          
           void Button6Click(object sender, EventArgs e)
           {
               
                if(twoPlayer.Checked == true)
                {
                     if(click6==0)
                     {
                           if(turn%2!=0)
                           {
                                button6.Text="X";
                           }
                           else
                           {
                                button6.Text="O";
                           }
                           turn++;
                           click6++;
                     }
                     else
                     {
                           MessageBox.Show("The button is already chosen!!!");
                     }
                }
                else if(vsCom.Checked == true)
                {
                     ButtonClick(ref button6);
                }
                else
            {
                MessageBox.Show("Please chose game mode!!!");
            }
                display();
                checkit();
           }
          
           void Button5Click(object sender, EventArgs e)
           {
               
                if(twoPlayer.Checked == true)
                {
                     if(click5==0)
                     {
                           if(turn%2!=0)
                           {
                                button5.Text="X";
                           }
                           else
                           {
                                button5.Text="O";
                           }
                           turn++;
                           click5++;
                     }
                     else
                     {
                           MessageBox.Show("The button is already chosen!!!");
                     }
                }
                else if(vsCom.Checked == true)
                {
                     ButtonClick(ref button5);
                }
                else
            {
                MessageBox.Show("Please chose game mode!!!");
            }
                display();
                checkit();
           }
          
           void Button7Click(object sender, EventArgs e)
           {
               
                if(twoPlayer.Checked == true)
                {
                     if(click7==0)
                     {
                           if(turn%2!=0)
                           {
                                button7.Text="X";
                           }
                           else
                           {
                                button7.Text="O";
                           }
                           turn++;
                           click7++;
                     }
                     else
                     {
                           MessageBox.Show("The button is already chosen!!!");
                     }
                }
                else if(vsCom.Checked == true)
                {
                     ButtonClick(ref button7);
                }
                else
            {
                MessageBox.Show("Please chose game mode!!!");
            }
                display();
                checkit();
           }
          
           void Button8Click(object sender, EventArgs e)
           {
               
                if(twoPlayer.Checked == true)
                {
                     if(click8==0)
                     {
                           if(turn%2!=0)
                           {
                                button8.Text="X";
                           }
                           else
                           {
                                button8.Text="O";
                           }
                           turn++;
                           click8++;
                     }
                     else
                     {
                           MessageBox.Show("The button is already chosen!!!");
                     }
                }
                else if(vsCom.Checked == true)
                {
                     ButtonClick(ref button8);
                }
                else
            {
                MessageBox.Show("Please chose game mode!!!");
            }
                display();
                checkit();
           }
          
           void Button9Click(object sender, EventArgs e)
           {
               
                if(twoPlayer.Checked == true)
                {
                     if(click9==0)
                     {
                           if(turn%2!=0)
                           {
                                button9.Text="X";
                           }
                           else
                           {
                                button9.Text="O";
                           }
                           turn++;
                           click9++;
                     }
                     else
                     {
                           MessageBox.Show("The button is already chosen!!!");
                     }
                }
                else if(vsCom.Checked == true)
                {
                     ButtonClick(ref button9);
                }
                else
            {
                MessageBox.Show("Please chose game mode!!!");
            }
                display();
                checkit();
           }
          
          
          
           void Button10Click(object sender, EventArgs e)
           {
                cleargame();
           }
          
           void Button11Click(object sender, EventArgs e)
           {
                P1score.Text="";
           P2score.Text="";
           player1=0;
           player2=0;
           cleargame();
           }
          
           void VsComCheckedChanged(object sender, EventArgs e)
           {
                if(vsCom.Checked == true)
                {
                     label3.Text="P1";
                     label4.Text="COM";
                     P1score.Text="";
                P2score.Text="";
                player1=0;
                player2=0;
                cleargame();
                }
           }
          
           void TwoPlayerCheckedChanged(object sender, EventArgs e)
           {
                if(twoPlayer.Checked == true)
                {
                     label3.Text="P1";
                     label4.Text="P2";
                     P1score.Text="";
                P2score.Text="";
                player1=0;
                player2=0;
                cleargame();
                }
           }
           private void ButtonClick(ref Button theButton)
        {
            if (vsCom.Checked)
            {
                if (theButton.Text == "")
                {
                    theButton.Text = "X";
                    ComPlay();
                    checkit();
                }
                else
                {
                    MessageBox.Show("The button is already chosen!!!");
                }
            }
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }
     }
}

TAMPILAN PRMOGRAMAN


Comments

Popular posts from this blog

Magang Industri di PT Citra Tubindo TBK

Assalamualaikum Sahabat, Pagi ini tanggal 31 Desember 2017, diluar sedang turun hujan. Aku sedang di kamar sambil memutar lagu virgoun-bukti. Sebelum tahun ini berlalu aku ingin membuat rangkaian cerita diawal tahun 2017 yang sudah berlalu. Why? karena bagiku tahun ini tahun istimewa untukku. Walaupun setiap tahun tentu saja selalu menyimpan ceritanya sendiri.  Izinkan aku menceritakan pengalaman yang aku dapatkan diawal tahun ini.   Statusku masih menjadi mahasiswa aktif tingkat akhir di Politeknik Negeri Batam dan harus menjalani proses magang. Terus magang dimana? di Citra Tubindo. Caranya gimana? Ok biar ku beritahu.  MAGANG DI CITRA TUBINDO TBK Polibatam dan Citra tubindo sudah menjalani kerja sama untuk program magang. Jadi kalau kalian berminat yang perlu kalian cari tahu di web polibatam atau ke TPS jurusan kalian. Terus aku taunya dari sana? enggak sih, saat itu kami memang diberi tahu langsung dari jurusan. Yap kami ditawari untuk magang disana. Waktu itu i

Tonsilektomi (Operasi Amandel)

Assalamualaikum sahabat semua. Beberapa hari yang lalu saya baru saja melakukan operasi amandel, nah saya mau sedikit sharing nih mekanisme pengajuan operasi amandel kalau teman-teman mau mengajukannya lewat BPJS.  Oke saya mulai pada tanggal 26 Juli lalu nah untuk awal kita melakukan pengecekan di klinik yang ada di BPJS yang tertera di kartu BPJS kita, Nah kemudian disana diperiksa biasa dengan dokter yang ada, waktu diperiksa dokter langsung mengajukan saya untuk operasi dan saya langsung meng-"IYA" kan setelah itu dari klinik itu saya dikasih surat rujukan di Rumah sakit Casa (Kelas C) karena untuk rujukan awal jadi harus kesana dulu kata perawatnya sih gitu. Tanggal 27 Julinya saya kerumah sakit Casa dan menemui dokter THT disana, jangan lupa untuk bawa surat rujukan, kartu BPJS dan KTP karena nanti mereka minta fotocopyanya sediain aja masing-masing 2 copyan, Setelah itu saya di periksa dokter THT disana,  nah kata dokternya sih yang bermasalah itu karena hidung sa

Translate dokument menggunakan Ms Word & Google Drive

Assalamualaikum Sahabat, Levo my best Selamat malam sahabat, berhubung tadi sore ada yang nanyain, "Gimana caranya translate dari google doc? " Jadi bagusnya aku share juga ke kalian deh, siapa tau ada yang belum tau, atau udah tau tapi lupa. Jadi kalian bisa manfaatin Ms Word dan Drive kalian selain untuk mengolah dokument disana juga terdapat fitur untuk translate juga lo sahabat. Nah disini aku bakal share dua aplikasi tersebut. So kalian bisa ikuti cara yang bakal aku tunjukin dibawah;  Translate Using Ms Word  Kalian bisa buka dokument/ file yang mau kalian tranlate, kebetulan Ms Word aku yang Ms Word 2016 jadi tampilannya seperti yang diatas.  Tampilan File yang akan di translate Selanjutnya, aku akan kasih foto tahapan yang bisa kalian ikuti kalian di foto nanti udah ada tahapan yang bisa kalian ikuti aku udah tambahin angka sesuai urutannya.  Pilih Review dan pilih icon translate Nah pada tahap ini pastikan kalian udah blok semua teks ya