public static void Main(string[] args) { bool exit = false; var figures = new Figures(); while (!exit) { ForConsole.PrintMenu(); exit = ForConsole.CheckCommand(ref figures); } foreach (var figure in figures.Lines) { Console.WriteLine(figure.Info()); } foreach (var figure in figures.Rectangles) { Console.WriteLine(figure.Info()); } foreach (var figure in figures.Circles) { Console.WriteLine(figure.Info()); } foreach (var figure in figures.Rounds) { Console.WriteLine(figure.Info()); } foreach (var figure in figures.Rings) { Console.WriteLine(figure.Info()); } Console.ReadKey(); }
public static bool CheckCommand(ref Figures figures) { Random r = new Random(); var command = SetCommand(); bool exit = false; switch (command) { case (int)FigureType.Line: { var figure = new Line(r.Next(1, 100), r.Next(1, 100), r.Next(1, 100)); figures.SetFigures(figure); Console.WriteLine(figure.Info()); break; } case (int)FigureType.Rectangle: { var figure = new Rectangle(r.Next(1, 100), r.Next(1, 100), r.Next(1, 100), r.Next(1, 100)); figures.SetFigures(figure); Console.WriteLine(figure.Info()); break; } case (int)FigureType.Circle: { var figure = new Circle(r.Next(1, 100), r.Next(1, 100), r.Next(1, 100)); figures.SetFigures(figure); Console.WriteLine(figure.Info()); break; } case (int)FigureType.Round: { var figure = new Round(r.Next(1, 100), r.Next(1, 100), r.Next(1, 100)); figures.SetFigures(figure); Console.WriteLine(figure.Info()); break; } case (int)FigureType.Ring: { var figure = new Ring(r.Next(1, 100), r.Next(1, 100), r.Next(1, 100), r.Next(1, 100)); figures.SetFigures(figure); Console.WriteLine(figure.Info()); break; } case 0: { exit = true; break; } default: { Console.WriteLine("Command does not exist."); exit = CheckCommand(ref figures); break; } } return(exit); }