/// <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(); } }
/// <summary> /// Returns right direction of current DirectionClass /// </summary> /// <returns>DirectionClass object</returns> public override DirectionClass GetRightDirection() { return(South.GetInstance()); }