blikk info infothek forum galerie sitemap

Tic Tac Toe Teil 2.

zur Aufgabenstellung

                    case 2:

                        Console.WriteLine(" " + a1 + " | " + spieler + " | " + c1 + " ");

                        Console.WriteLine("-----------");

                        Console.WriteLine(" " + a2 + " | " + b2 + " | " + c2 + " ");

                        Console.WriteLine("-----------");

                        Console.WriteLine(" " + a3 + " | " + b3 + " | " + c3 + " ");

                        b1 = 'x';

                        break;

 

                    case 3:

                        Console.WriteLine(" " + a1 + " | " + b1 + " | " + spieler + " ");

                        Console.WriteLine("-----------");

                        Console.WriteLine(" " + a2 + " | " + b2 + " | " + c2 + " ");

                        Console.WriteLine("-----------");

                        Console.WriteLine(" " + a3 + " | " + b3 + " | " + c3 + " ");

                        c1 = 'x';

                        break;

 

                    case 4:

                        Console.WriteLine(" " + a1 + " | " + b1 + " | " + c1 + " ");

                        Console.WriteLine("-----------");

                        Console.WriteLine(" " + spieler + " | " + b2 + " | " + c2 + " ");

                        Console.WriteLine("-----------");

                        Console.WriteLine(" " + a3 + " | " + b3 + " | " + c3 + " ");

                        a2 = 'x';

                        break;

 

                    case 5:

                        Console.WriteLine(" " + a1 + " | " + b1 + " | " + c1 + " ");

                        Console.WriteLine("-----------");

                        Console.WriteLine(" " + a2 + " | " + spieler + " | " + c2 + " ");

                        Console.WriteLine("-----------");

                        Console.WriteLine(" " + a3 + " | " + b3 + " | " + c3 + " ");

                        b2 = 'x';

                        break;

 

                    case 6:

                        Console.WriteLine(" " + a1 + " | " + b1 + " | " + c1 + " ");

                        Console.WriteLine("-----------");

                        Console.WriteLine(" " + a2 + " | " + b2 + " | " + spieler + " ");

                        Console.WriteLine("-----------");

                        Console.WriteLine(" " + a3 + " | " + b3 + " | " + c3 + " ");

                        c2 = 'x';

                        break;

 

                    case 7:

                        Console.WriteLine(" " + a1 + " | " + b1 + " | " + c1 + " ");

                        Console.WriteLine("-----------");

                        Console.WriteLine(" " + a2 + " | " + b2 + " | " + c2 + " ");

                        Console.WriteLine("-----------");

                        Console.WriteLine(" " + spieler + " | " + b3 + " | " + c3 + " ");

                        a3 = 'x';

                        break;

 

                    case 8:

                        Console.WriteLine(" " + a1 + " | " + b1 + " | " + c1 + " ");

                        Console.WriteLine("-----------");

                        Console.WriteLine(" " + a2 + " | " + b2 + " | " + c2 + " ");

                        Console.WriteLine("-----------");

                        Console.WriteLine(" " + a3 + " | " + spieler + " | " + c3 + " ");

                        b3 = 'x';

                        break;

 

                    case 9:

                        Console.WriteLine(" " + a1 + " | " + b1 + " | " + c1 + " ");

                        Console.WriteLine("-----------");

                        Console.WriteLine(" " + a2 + " | " + b2 + " | " + c2 + " ");

                        Console.WriteLine("-----------");

                        Console.WriteLine(" " + a3 + " | " + b3 + " | " + spieler + " ");

                        c3 = 'x';

                        break;

                }

                //Dem Benutzer wird vorgegaukelt der Computer würde rechnen

                Thread.Sleep(3000);

                Console.Clear();

                Console.WriteLine("Der Computer rechnet... (Please wait...)");

                Thread.Sleep(3500);

                //Der Computer gibt seinen Zug über Zufall ab ohne Algorythmus

                Random zufall = new Random();

                int cpuzug = zufall.Next(1, 10);

 

                //Der Computer moved + wird ausgeschlossen das er einer des Gegenüberspielers überschreibt

 

                if (cpuzug == 1)

                {

                    if (a1 != 'x')

                    {

                        a1 = 'o';

                    }

                }

                else if (cpuzug == 2)

                {

                    if (b1 != 'x')

                    {

                        b1 = 'o';

                    }

                }

                else if (cpuzug == 3)

                {

                    if (c1 != 'x')

                    {

                        c1 = 'o';

                    }

                }

 

nach oben
punkt   seitenbereich schließen

Links

Aufgabenstellung
1. Teil des Spiels
3. Teil des Spiels