Advertisement
pegasus975

SpaceCar.cs

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