TrabalhosGratuitos.com - Trabalhos, Monografias, Artigos, Exames, Resumos de livros, Dissertações
Pesquisar

Jogo Da Velha Simples

Artigo: Jogo Da Velha Simples. Pesquise 860.000+ trabalhos acadêmicos

Por:   •  8/9/2014  •  5.446 Palavras (22 Páginas)  •  455 Visualizações

Página 1 de 22

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace JogoDaVelha

{

class Program

{

static void Main(string[] args)

{

Console.WriteLine("JOGO DA VELHA \n\n" + "JOGADOR 1: 'X' " + "JOGADOR 2: 'O' \n");

int jogada1, jogada2;

String[,] tabuleiro = new String[3, 3];

bool ganhou = true;

tabuleiro[0, 0] = "7";

tabuleiro[0, 1] = "8";

tabuleiro[0, 2] = "9";

tabuleiro[1, 0] = "4";

tabuleiro[1, 1] = "5";

tabuleiro[1, 2] = "6";

tabuleiro[2, 0] = "1";

tabuleiro[2, 1] = "2";

tabuleiro[2, 2] = "3";

do

{

Console.WriteLine("");

for (int t = 0; t < 3; t++)

{

Console.Write(" | " + tabuleiro[0, t]);

}

Console.Write(" | \n");

for (int t = 0; t < 3; t++)

{

Console.Write(" | " + tabuleiro[1, t]);

}

Console.Write(" | \n");

for (int t = 0; t < 3; t++)

{

Console.Write(" | " + tabuleiro[2, t]);

}

Console.Write(" | \n");

Console.WriteLine("");

try

{

Console.Write("vez do Jogador 1: ");

jogada1 = int.Parse(Console.ReadLine());

if (jogada1 == 7)

{

tabuleiro[0, 0] = "X";

}

else if (jogada1 == 8)

{

tabuleiro[0, 1] = "X";

}

else if (jogada1 == 9)

{

tabuleiro[0, 2] = "X";

}

else if (jogada1 == 4)

{

tabuleiro[1, 0] = "X";

}

else if (jogada1 == 5)

{

tabuleiro[1, 1] = "X";

}

else if (jogada1 == 6)

{

tabuleiro[1, 2] = "X";

}

else if (jogada1 == 1)

{

tabuleiro[2, 0] = "X";

}

else if (jogada1 == 2)

{

tabuleiro[2, 1] = "X";

}

else if (jogada1 == 3)

{

tabuleiro[2, 2] = "X";

}

Console.Clear();

Console.WriteLine("");

for (int t = 0; t < 3; t++)

{

Console.Write(" | " + tabuleiro[0, t]);

}

Console.Write(" | \n");

for (int t = 0; t < 3; t++)

{

Console.Write(" | " + tabuleiro[1, t]);

}

Console.Write(" | \n");

...

Baixar como (para membros premium)  txt (9.7 Kb)  
Continuar por mais 21 páginas »
Disponível apenas no TrabalhosGratuitos.com