示例#1
0
 public void TurnNeedle(NeedleTurn needleTurn)
 {
     if (needleTurn == NeedleTurn.RIGHT)
     {
         _direction = _direction.Right;
     }
     else
     {
         _direction = _direction.Left;
     }
 }
示例#2
0
        public Compass(Char initialPosition)
        {
            compassDictionary = new Dictionary <Char, CompassDirection>();

            compassDictionary.Add('N', new CompassDirection('N'));
            compassDictionary.Add('E', new CompassDirection('E'));
            compassDictionary.Add('S', new CompassDirection('S'));
            compassDictionary.Add('W', new CompassDirection('W'));

            compassDictionary['N'].setAdjacent(compassDictionary['W'], compassDictionary['E']);
            compassDictionary['E'].setAdjacent(compassDictionary['N'], compassDictionary['S']);
            compassDictionary['S'].setAdjacent(compassDictionary['E'], compassDictionary['W']);
            compassDictionary['W'].setAdjacent(compassDictionary['S'], compassDictionary['N']);

            this._direction = compassDictionary[initialPosition];
        }
示例#3
0
 public void setAdjacent(CompassDirection Left, CompassDirection Right)
 {
     this._left  = Left;
     this._right = Right;
 }
示例#4
0
 public void SetDirection(Char direction)
 {
     this._direction = compassDictionary[direction];
 }