I'm trying to read a string typed in the console, which is halfway through the code, but what happens is that it passes straight through and displays the final information.
using System;
namespace Viernes
{
class Program
{
static void Main(string[] args)
{
int xDig = -1, yDig = -1;
char pCardeal = 'N';
//Verificando a validade
while (xDig < 0 && yDig < 0)
{
Console.Write("Digite as coordenadas \nx: ");
xDig = Convert.ToInt32(Console.ReadLine());
Console.Write("y: ");
yDig = Convert.ToInt32(Console.ReadLine());
}
Console.Write("Cardeal 'N' 'S' 'L' 'O': ");
pCardeal = Convert.ToChar(Console.Read());
pCardeal = Char.ToUpper(pCardeal);
//Comandos
Console.WriteLine("Digite alguns comandos, 'E'squerda, 'D'ireita, 'A'vançar.");
string str = Console.ReadLine();
str = str.ToUpper();
char[] Comands = str.ToCharArray();
//Obj
SpaceCar sp = new SpaceCar(xDig, yDig, pCardeal);
foreach (var separaLetras in Comands)
{
switch (separaLetras)
{
case 'E':
sp.girarEsquerda();
break;
case 'D':
sp.girarDireita();
break;
case 'A':
sp.avancarBloco(xDig, yDig);
break;
}
}
//Imprimindo Destino
Console.Write("Coordenadas: {0}{1}{2}", sp.PosicaoX,sp.PosicaoY, sp.PosicaoCardial);
Console.WriteLine("Press Any Key to Exit");
Console.ReadKey();
}
}
}
Complement of class SpaceCar
in another PasteBin .