/// <summary> /// Given the application parameters, creates regular polygon and depending on the option: saves it to default file or displays it on console /// /// </summary> /// <param name="parameters">Already parsed application parameters</param> private static void ProcessInput(AppParameters parameters) { RegularPolygonFactory factory = new RegularPolygonFactory(); try { RegularPolygon polygon = factory.CreateRegularPolygon(parameters.NumberOfVertices, parameters.SideLength, DefaultInitialVertex); switch (parameters.Option) { case AppParameters.ProcessType.DisplayOnConsole: DU.DisplayText(polygon.ToString()); DU.DisplayText("Successfully completed operation", DU.InformationType.OnSuccess); break; case AppParameters.ProcessType.SaveToFile: SavePolygonToFile(DefaultFilePath, polygon); break; } } catch (RegularPolygonFactoryLogicalException e) { DU.DisplayText(e.Message, DU.InformationType.OnError); } }
private static void Main(string[] args) { try { AppParameters parameters = ExtractParametersFromInput(args); ProcessInput(parameters); } catch (InputValidationException e) { DU.DisplayText(e.Message, DU.InformationType.OnError); } DU.DisplayText("Press any key to close the program..."); Console.ReadKey(); }