pegasus975

Program.cs

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