Advertisement
pegasus975

Program.cs

Jun 23rd, 2014
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.89 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 Viernes
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int xDig = -1, yDig = -1;
  14.             char pCardeal = 'N';
  15.            //Verificando a validade
  16.            
  17.             while (xDig < 0 && yDig < 0)
  18.             {
  19.                 Console.Write("Digite as coordenadas \nx: ");
  20.                 xDig = Convert.ToInt32(Console.ReadLine());
  21.  
  22.                 Console.Write("y: ");
  23.                 yDig = Convert.ToInt32(Console.ReadLine());
  24.             }
  25.             Console.Write("Cardeal 'N' 'S' 'L' 'O': ");
  26.             pCardeal = Convert.ToChar(Console.Read());
  27.             pCardeal = Char.ToUpper(pCardeal);
  28.            
  29.             //Comandos
  30.             Console.WriteLine("Digite alguns comandos, 'E'squerda, 'D'ireita, 'A'vançar.");
  31.             string str = Console.ReadLine();
  32.  
  33.            
  34.  
  35.             str = str.ToUpper();
  36.             char[] Comands = str.ToCharArray();
  37.            
  38.             //Obj
  39.             SpaceCar sp = new SpaceCar(xDig, yDig, pCardeal);
  40.  
  41.            
  42.  
  43.            
  44.             foreach (var separaLetras in Comands)
  45.             {
  46.                 switch (separaLetras)
  47.                 {
  48.                     case 'E':
  49.                         sp.girarEsquerda();
  50.                     break;
  51.                     case 'D':
  52.                         sp.girarDireita();
  53.                     break;
  54.                     case 'A':
  55.                         sp.avancarBloco(xDig, yDig);
  56.                     break;
  57.                 }
  58.             }
  59.             //Imprimindo Destino
  60.             Console.Write("Coordenadas: {0}{1}{2}", sp.PosicaoX,sp.PosicaoY, sp.PosicaoCardial);
  61.             Console.WriteLine("Press Any Key to Exit");
  62.             Console.ReadKey();
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement