mardi 25 septembre 2018

problem to create pattern like minesweeper with C#

first at all, i'm new at C#, so, I apologize if I ask something somewhat "so newbie". Well, here the thing:

I'm trying to create a pattern, just like the game: Minesweeper 'cause i'm making a simple game, a chess game, so my big problem right now is that i can't create the columns efficiently, so, here's my code:

class chessGame
{
    static void Main(string[] args)
    {
        const string EX = "X";
        const string OU = "O";
        const int VALUE_X = 8;

        int numRows = 0;
        int numCol = 0;

        while (numRows < VALUE_X)
        {
            for (numCol = 0; numCol < VALUE_X; numCol++)
            {
                Console.WriteLine(OU);
            }
            for (numRows = 0; numRows < numCol; numRows++)
            {
                Console.WriteLine(EX);
            }
            Console.WriteLine();
        }
        Console.ReadLine();
    }
}

also, i don't know at all if that's the way create the columns and rows with that nested loop, so, if someone can help me with this, or just someone can help me to do it right with my actual code, thank you so much!

and for the record, here's what i see in the console right now:

enter image description here

beforehand, thank you for your advices to all of you guys!

Aucun commentaire:

Enregistrer un commentaire