Advertisement
dacanizares

Triki - WIP Part 1

Jan 18th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Triki
  8. {
  9.     class Program
  10.     {
  11.         static int[,] Tablero = new int[3, 3];
  12.  
  13.         static bool Jugador = true;
  14.        
  15.         static void Pintar()
  16.         {
  17.             Console.WriteLine("  0 1 2");
  18.             for (int i = 0; i < 3; ++i)
  19.             {
  20.                 Console.Write(i + " ");
  21.                 for (int j = 0; j < 3; ++j)
  22.                 {
  23.                     switch (Tablero[i, j])
  24.                     {
  25.                         case 0: Console.Write(". "); break;
  26.                         case 1: Console.Write("X "); break;
  27.                         case 2: Console.Write("O "); break;
  28.                     }
  29.                    
  30.                 }
  31.                 Console.WriteLine("");
  32.             }
  33.         }
  34.  
  35.         static void PedirJugada()
  36.         {
  37.             int jugadorActual = Jugador ? 1 : 2;
  38.             Console.WriteLine($"Es el turno del jugador {jugadorActual}");
  39.  
  40.             Console.WriteLine("Digite una fila: ");
  41.             int f = int.Parse(Console.ReadLine());
  42.             Console.WriteLine("Digite una columna: ");
  43.             int c = int.Parse(Console.ReadLine());
  44.  
  45.             Tablero[f, c] = jugadorActual;
  46.         }
  47.  
  48.         static void Main(string[] args)
  49.         {
  50.             while (true)
  51.             {
  52.                 Pintar();
  53.                 PedirJugada();
  54.  
  55.                 Jugador = !Jugador;
  56.             }            
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement