예제 #1
0
 /// <summary>
 /// Returns instance of the object according to Singleton Design Pattern
 /// </summary>
 /// <returns>Instance of the object</returns>
 public static South GetInstance()
 {
     if (_instance == null)
     {
         _instance = new South();
     }
     return(_instance);
 }
        /// <summary>
        /// Factory method that returns direction according to given directionCode char
        /// </summary>
        /// <param name="directionCode">directionCode char</param>
        /// <returns>Direction object</returns>
        public static DirectionClass GetDirection(char directionCode)
        {
            switch (directionCode)
            {
            case (char)Directions.North:
                return(North.GetInstance());

            case (char)Directions.East:
                return(East.GetInstance());

            case (char)Directions.South:
                return(South.GetInstance());

            case (char)Directions.West:
                return(West.GetInstance());

            default:
                throw new InvalidDirectionException();
            }
        }
예제 #3
0
 /// <summary>
 /// Returns right direction of current DirectionClass
 /// </summary>
 /// <returns>DirectionClass object</returns>
 public override DirectionClass GetRightDirection()
 {
     return(South.GetInstance());
 }