pegasus975

SpaceCar.cs

Jun 22nd, 2014
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.73 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 SpaceCar
  10.     {
  11.         //POSICAO X
  12.         private int _posX;
  13.  
  14.         public int PosicaoX
  15.         {
  16.             get { return _posX; }
  17.             set { _posX = value; }
  18.         }
  19.         //POSICAO Y
  20.         private int _posY;
  21.  
  22.         public int PosicaoY
  23.         {
  24.             get { return _posY; }
  25.             set { _posY = value; }
  26.         }
  27.         //POSICAO CARDIAL
  28.         private char _posCardial;
  29.  
  30.         public char PosicaoCardial
  31.         {
  32.             get { return _posCardial; }
  33.             set { _posCardial = value; }
  34.         }
  35.         //METHODS
  36.         public SpaceCar(int xDigitado, int yDigitado)//CONSTRUTOR
  37.         {
  38.             _posX = xDigitado;
  39.             _posY = yDigitado;
  40.             _posCardial = 'N';
  41.  
  42.         }
  43.         public void requisicaoMovimento(int x, int y, string comand)
  44.         {
  45.  
  46.         }
  47.         public void girarEsquerda()
  48.         {
  49.             switch (this.PosicaoCardial)
  50.             {
  51.                 case 'N':
  52.                     this.PosicaoCardial = 'O';
  53.                     break;
  54.                 case 'L':
  55.                     this.PosicaoCardial = 'N';
  56.                     break;
  57.                 case 'S':
  58.                     this.PosicaoCardial = 'L';
  59.                     break;
  60.                 case 'O':
  61.                     this.PosicaoCardial = 'S';
  62.                     break;
  63.             }
  64.         }
  65.         public void girarDireita()
  66.         {
  67.             switch (this.PosicaoCardial)
  68.             {
  69.                 case 'N':
  70.                     this.PosicaoCardial = 'L';
  71.                     break;
  72.                 case 'L':
  73.                     this.PosicaoCardial = 'S';
  74.                     break;
  75.                 case 'S':
  76.                     this.PosicaoCardial = 'O';
  77.                     break;
  78.                 case 'O':
  79.                     this.PosicaoCardial = 'N';
  80.                     break;
  81.             }
  82.         }
  83.         public void avancarBloco(int x, int y)
  84.         {
  85.             switch (this.PosicaoCardial)
  86.             {
  87.                 case 'N':
  88.                     this._posX += 0;
  89.                     this._posY += 1;
  90.                     break;
  91.                 case 'S':
  92.                     this._posX += 0;
  93.                     this._posY -= 1;
  94.                     break;
  95.                 case 'L':
  96.                     this._posX += 1;
  97.                     this._posY += 0;
  98.                     break;
  99.                 case 'O':
  100.                      this._posX -= 1;
  101.                     this._posY += 0;
  102.                     break;
  103.             }
  104.  
  105.         }      
  106.     }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment