Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 817077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:56:11+00:00 2026-05-15T01:56:11+00:00

This is for a tic tac toe game. I need help making a check

  • 0

This is for a tic tac toe game. I need help making a check statement to see if all the controls’ Texts are non-blank, and if they are, you have a draw (if someone had won the previous code would have discovered that). Can you give me a good example using my code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace MyGame
{
    public class Result1
    {


        static private int[,] Winners = new int[,]
                   {
                       // main gameplay Ex: if x is on 0,1,2 x is the winner
                        {0,1,2},
                        {3,4,5},
                        {6,7,8},
                        {0,3,6},
                        {1,4,7},
                        {2,5,8},
                        {0,4,8},
                        {2,4,6},
                   };


        static public bool CheckWinner(Button[] myControls)
        {
            //bolean statement to check for the winner 
            bool gameOver = false;
            for (int i = 0; i < 8; i++)
            {
                int a = Winners[i, 0];
                int b = Winners[i, 1];
                int c = Winners[i, 2];

                Button b1 = myControls[a], b2 = myControls[b], b3 = myControls[c];
                if (b1.Text == "" || b2.Text == "" || b3.Text == "")
                    continue;

                if (b1.Text == b2.Text && b2.Text == b3.Text)
                {

                    b1.BackColor = b2.BackColor = b3.BackColor = Color.LightCoral;
                    b1.Font = b2.Font = b3.Font = new System.Drawing.Font("Microsoft Sans Serif", 32F, System.Drawing.FontStyle.Italic & System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
                    gameOver = true;
                    xWinnerForm xWinnerForm = new xWinnerForm();
                    xWinnerForm.ShowDialog(); //only works with show not showDialog method gets overloaded  (b1.Text + " is the Winner"); to get around this I added and image showing the last player


                }


            }


        return gameOver;
       }





    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:56:12+00:00Added an answer on May 15, 2026 at 1:56 am

    Observe that you already have code that will check for an empty space and that in all cases where you find an empty space there isn’t a draw. If you iterate through all possible spaces and haven’t found a winner or an empty space, then it clearly is a draw.

    static public bool CheckWinner(Button[] myControls)
    {
        //bolean statement to check for the winner 
        bool gameOver = false;
        bool foundEmpty = false;
        for (int i = 0; i < 8; i++)
        {
            int a = Winners[i, 0];
            int b = Winners[i, 1];
            int c = Winners[i, 2];
    
            Button b1 = myControls[a], b2 = myControls[b], b3 = myControls[c];
            if (b1.Text == "" || b2.Text == "" || b3.Text == "")
            {
                foundEmpty = true;
                continue;
            }
    
            if (b1.Text == b2.Text && b2.Text == b3.Text)
            {
    
                b1.BackColor = b2.BackColor = b3.BackColor = Color.LightCoral;
                b1.Font = b2.Font = b3.Font = new System.Drawing.Font("Microsoft Sans Serif", 32F, System.Drawing.FontStyle.Italic & System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
                gameOver = true;
                xWinnerForm xWinnerForm = new xWinnerForm();
                xWinnerForm.ShowDialog(); //only works with show not showDialog method gets overloaded  (b1.Text + " is the Winner"); to get around this I added and image showing the last player
    
    
            }
    
    
        }
        if (!gameOver && !foundEmpty)
        {
           // must be a draw
           gameOver = true;
        }
    
        return gameOver;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 452k
  • Answers 452k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you want to display the actual HTML as stored… May 15, 2026 at 9:21 pm
  • Editorial Team
    Editorial Team added an answer Are they the same commands? Try print commands.__file__ in each.… May 15, 2026 at 9:21 pm
  • Editorial Team
    Editorial Team added an answer I guess you'll have to do it manually. A quick… May 15, 2026 at 9:21 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.