Exemple #1
0
 public void TurnNeedle(NeedleTurn needleTurn)
 {
     if (needleTurn == NeedleTurn.RIGHT)
     {
         _direction = _direction.Right;
     }
     else
     {
         _direction = _direction.Left;
     }
 }
Exemple #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];
        }
Exemple #3
0
 public void setAdjacent(CompassDirection Left, CompassDirection Right)
 {
     this._left  = Left;
     this._right = Right;
 }
Exemple #4
0
 public void SetDirection(Char direction)
 {
     this._direction = compassDictionary[direction];
 }