Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Viernes
- {
- class SpaceCar
- {
- //POSICAO X
- private int _posX;
- public int PosicaoX
- {
- get { return _posX; }
- set { _posX = value; }
- }
- //POSICAO Y
- private int _posY;
- public int PosicaoY
- {
- get { return _posY; }
- set { _posY = value; }
- }
- //POSICAO CARDIAL
- private char _posCardial;
- public char PosicaoCardial
- {
- get { return _posCardial; }
- set { _posCardial = value; }
- }
- //METHODS
- public SpaceCar(int xDigitado, int yDigitado, char pCardeal)//CONSTRUTOR
- {
- _posX = xDigitado;
- _posY = yDigitado;
- _posCardial = pCardeal;
- }
- public void girarEsquerda()
- {
- switch (this.PosicaoCardial)
- {
- case 'N':
- this._posCardial = 'O';
- break;
- case 'L':
- this._posCardial = 'N';
- break;
- case 'S':
- this._posCardial = 'L';
- break;
- case 'O':
- this._posCardial = 'S';
- break;
- }
- }
- public void girarDireita()
- {
- switch (this._posCardial)
- {
- case 'N':
- this._posCardial = 'L';
- break;
- case 'L':
- this._posCardial = 'S';
- break;
- case 'S':
- this._posCardial = 'O';
- break;
- case 'O':
- this._posCardial = 'N';
- break;
- }
- }
- public void avancarBloco(int x, int y)
- {
- switch (this._posCardial)
- {
- case 'N':
- this._posX += 0;
- this._posY += 1;
- break;
- case 'S':
- this._posX += 0;
- this._posY -= 1;
- break;
- case 'L':
- this._posX += 1;
- this._posY += 0;
- break;
- case 'O':
- this._posX -= 1;
- this._posY += 0;
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement