Пример #1
0
        private void TurnLeft()
        {
            switch (CurrentState.Orientation)
            {
            case OrientationEnum.North:
                CurrentState = CurrentState.ChangeOrientation(OrientationEnum.West);
                break;

            case OrientationEnum.West:
                CurrentState = CurrentState.ChangeOrientation(OrientationEnum.South);
                break;

            case OrientationEnum.South:
                CurrentState = CurrentState.ChangeOrientation(OrientationEnum.East);
                break;

            case OrientationEnum.East:
                CurrentState = CurrentState.ChangeOrientation(OrientationEnum.North);
                break;

            default:
                throw new InvalidOperationException();
            }
        }
Пример #2
0
 public Robot(int battery, int x, int y, OrientationEnum orientation)
 {
     Battery      = battery;
     CurrentState = new CleaningRobotState(x, y, orientation);
 }