jak jest kolej X to się restartują zmienne pole 1 ,2 ,3, 4, 5, 6,7, 8, 9 kod na dole
namespace tic_tac_toe
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Witaj w Tic Tac Toe")
string poel1 = "1,";
string poel2 = "2,";
string poel3 = "3";
string poel4 = "4,";
string poel5 = "5,";
string poel6 = "6";
string poel7 = "7,";
string poel8 = "8,";
string poel9 = "9";
Console.WriteLine(poel1 + poel2 + poel3);
Console.WriteLine(poel4 + poel5 + poel6);
Console.WriteLine(poel7 + poel8 + poel9);
ruchO(poel1, poel2, poel3, poel4, poel5, poel6, poel7, poel8, poel9);
ruchX(poel1, poel2, poel3, poel4, poel5, poel6, poel7, poel8, poel9);
}
static void ruchO(string pole1, string pole2, string pole3, string pole4, string pole5, string pole6, string pole7, string pole8, string pole9)
{
Console.WriteLine("Ruch ma O");
var wybor = Console.ReadLine();
if (wybor.ToString() == 1.ToString())
{
pole1 = "O,";
}
if (wybor.ToString() == 2.ToString())
{
pole2 = "O,";
}
if (wybor.ToString() == 3.ToString())
{
pole3 = "O";
}
if (wybor.ToString() == 4.ToString())
{
pole4 = "O,";
}
if (wybor.ToString() == 5.ToString())
{
pole5 = "O,";
}
if (wybor.ToString() == 6.ToString())
{
pole6 = "O";
}
if (wybor.ToString() == 7.ToString())
{
pole7 = "O,";
}
if (wybor.ToString() == 8.ToString())
{
pole8 = "O,";
}
if (wybor.ToString() == 9.ToString())
{
pole9 = "O";
}
Console.WriteLine(pole1 + pole2 + pole3);
Console.WriteLine(pole4 + pole5 + pole6);
Console.WriteLine(pole7 + pole8 + pole9);
}
static void ruchX(string pole1, string pole2, string pole3, string pole4, string pole5, string pole6, string pole7, string pole8, string pole9)
{
Console.WriteLine("Ruch ma X");
var wybor = Console.ReadLine();
if (wybor.ToString() == 1.ToString())
{
pole1 = "X,";
}
if (wybor.ToString() == 2.ToString())
{
pole2 = "X,";
}
if (wybor.ToString() == 3.ToString())
{
pole3 = "X";
}
if (wybor.ToString() == 4.ToString())
{
pole4 = "X,";
}
if (wybor.ToString() == 5.ToString())
{
pole5 = "X,";
}
if (wybor.ToString() == 6.ToString())
{
pole6 = "X";
}
if (wybor.ToString() == 7.ToString())
{
pole7 = "X,";
}
if (wybor.ToString() == 8.ToString())
{
pole8 = "X,";
}
if (wybor.ToString() == 9.ToString())
{
pole9 = "X";
}
Console.WriteLine(pole1 + pole2 + pole3);
Console.WriteLine(pole4 + pole5 + pole6);
Console.WriteLine(pole7 + pole8 + pole9);
}
}
}```