Exemple #1
0
 /// <summary>
 /// Returns instance of the object according to Singleton Design Pattern
 /// </summary>
 /// <returns>Instance of the object</returns>
 public static East GetInstance()
 {
     if (_instance == null)
     {
         _instance = new East();
     }
     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();
            }
        }
Exemple #3
0
 /// <summary>
 /// Returns right direction of current DirectionClass
 /// </summary>
 /// <returns>DirectionClass object</returns>
 public override DirectionClass GetRightDirection()
 {
     return(East.GetInstance());
 }