-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
64 lines (55 loc) · 2.13 KB
/
Program.cs
File metadata and controls
64 lines (55 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using tabuleiro;
using Xadrez;
namespace AppConsoleJogoXadrez
{
/// <summary>
/// Projeto Udemy - Criação de um jogo de Xadrez.
/// Aplicando técnicas de Programação orientada a objetos (POO).
/// </summary>
class Program
{
static void Main(string[] args)
{
try
{
PartidaDeXadrez partida = new PartidaDeXadrez();
while (!partida.terminada)
{
try
{
Console.Clear();
Console.Title = "Projeto Udemy - Jogo de Xadrez";
Tela.imprimirPartida(partida);
Console.WriteLine();
Console.Write("Origem: ");
Posicao origem = Tela.LerPosicaoXadrez().ToPosisao();
partida.validarPosicaoOrigem(origem);
bool[,] posicoesPossiveis = partida.tab.peca(origem).movimentosPossiveis();
Console.Clear();
Tela.imprimirTabuleiro(partida.tab, posicoesPossiveis);
Console.WriteLine();
Console.Write("Destino: ");
Posicao destino = Tela.LerPosicaoXadrez().ToPosisao();
partida.validarPosicaoDeDestino(origem,destino);
partida.realizaJogada(origem, destino);
}
catch (TabuleiroException e)
{
Console.WriteLine(e.Message);
//Incluido Console.ReadLine() para "Travar a mensagem de erro na tela".
Console.ReadLine();
}
}
Console.Clear();
Tela.imprimirPartida(partida);
// Incluido para travar a tela.
Console.ReadLine();
}
catch (TabuleiroException e)
{
Console.WriteLine(e.Message);
}
}
}
}