private static void CreateCircle(string[] splitCommand) { if (splitCommand.Length == 5) { double centerX = ParseToDouble(splitCommand[2]); double centerY = ParseToDouble(splitCommand[3]); double radius = ParseToDouble(splitCommand[4]); if (radius <= 0) { Console.WriteLine("Radius less zero"); } if (!(Double.IsNaN(centerX) || Double.IsNaN(centerY) || Double.IsNaN(radius))) { var circle = new Circle(centerX, centerY, radius, (uint)Figure.GetLastID() + 1); Console.WriteLine(circle.ToString()); Figure.AddToList(circle); } else { Console.WriteLine("Incorrect syntax"); } } else { Console.WriteLine("Unknown command"); } }
/// <summary> /// Тest figures /// </summary> private static void CreateTestFigure() { Figure.AddToList(new Circle(0.5, -0.5, 3, 1)); Figure.AddToList(new Square(-1, 0, 2, 2)); Figure.AddToList(new Rectangle(-1, 0, 2, 2, 3)); Figure.AddToList(new Circle(5, 5, 1, 4)); Figure.AddToList(new Circle(4.5, -4.5, 3, 5)); Figure.AddToList(new Rectangle(10, 0, 2, 2, 6)); Figure.AddToList(new Square(0, 1, 2, 7)); Figure.AddToList(new Square(99, 99, 1, 8)); }
private static void CreateSquare(string[] splitCommand) { if (splitCommand.Length == 5) { double left = ParseToDouble(splitCommand[2]); double top = ParseToDouble(splitCommand[3]); double side = ParseToDouble(splitCommand[4]); if (!(Double.IsNaN(left) || Double.IsNaN(top) || Double.IsNaN(side))) { var square = new Square(left, top, side, (uint)Figure.GetLastID() + 1); Console.WriteLine(square.ToString()); Figure.AddToList(square); } else { Console.WriteLine("Incorrect syntax"); } } else { Console.WriteLine("Unknown command"); } }
private static void CreateRectangle(string[] splitCommand) { if (splitCommand.Length == 6) { double left = ParseToDouble(splitCommand[2]); double top = ParseToDouble(splitCommand[3]); double width = ParseToDouble(splitCommand[4]); double height = ParseToDouble(splitCommand[5]); if (!(Double.IsNaN(left) || Double.IsNaN(top) || Double.IsNaN(width) || Double.IsNaN(height))) { var rectangle = new Rectangle(left, top, width, height, (uint)Figure.GetLastID() + 1); Console.WriteLine(rectangle.ToString()); Figure.AddToList(rectangle); } else { Console.WriteLine("Incorrect syntax"); } } else { Console.WriteLine("Unknown command"); } }