static void Main(string[] args) { /*вычисление углов в градусах * вычисление длин диагоналей * вычисление длин сторон * вычисление периметра * вычисление площади */ double a, b, c, d, d1, d2; Console.WriteLine("\n\nPARALLELOGRAM:"); Parallelogram parallelogram = new Parallelogram(-3, 1, -4, 4, 0, 4, 1, 1); parallelogram.DisplayPoints(); parallelogram.GetAngles(out a, out b, out c, out d); Console.WriteLine($"ANGLES:\nA = {a}\nB = {b}\nC = {c}\nD = {d}"); parallelogram.GetDiagonalsLength(out d1, out d2); Console.WriteLine($"\nDIAGONALS:\nd1 = {d1}\nd2 = {d2}"); parallelogram.GetSides(out a, out b, out c, out d); Console.WriteLine($"\nSIDES:\na = {a}\nb = {b}\nc = {c}\nd = {d}"); Console.WriteLine($"Perimeter = {parallelogram.GetPerimeter()}"); Console.WriteLine($"Area = {parallelogram.GetArea()}"); Console.WriteLine("\n\nRHOMBUS:"); Rhombus rhombus = new Rhombus(-1, -2, 0, 0, 1, -2, 0, -3); rhombus.DisplayPoints(); rhombus.GetAngles(out a, out b, out c, out d); Console.WriteLine($"ANGLES:\nA = {a}\nB = {b}\nC = {c}\nD = {d}"); rhombus.GetDiagonalsLength(out d1, out d2); Console.WriteLine($"\nDIAGONALS:\nd1 = {d1}\nd2 = {d2}"); rhombus.GetSides(out a, out b, out c, out d); Console.WriteLine($"\nSIDES:\na = {a}\nb = {b}\nc = {c}\nd = {d}"); Console.WriteLine($"Perimeter = {rhombus.GetPerimeter()}"); Console.WriteLine($"Area = {rhombus.GetArea()}"); Console.WriteLine("\n\nSQUARE:"); Square sqaure = new Square(1, 1, 1, 3, 3, 3, 3, 1); sqaure.DisplayPoints(); sqaure.GetAngles(out a, out b, out c, out d); Console.WriteLine($"ANGLES:\nA = {a}\nB = {b}\nC = {c}\nD = {d}"); sqaure.GetDiagonalsLength(out d1, out d2); Console.WriteLine($"\nDIAGONALS:\nd1 = {d1}\nd2 = {d2}"); sqaure.GetSides(out a, out b, out c, out d); Console.WriteLine($"\nSIDES:\na = {a}\nb = {b}\nc = {c}\nd = {d}"); Console.WriteLine($"Perimeter = {sqaure.GetPerimeter()}"); Console.WriteLine($"Area = {sqaure.GetArea()}");; Console.ReadKey(); }
static void Main(string[] args) { Console.Title = "Lab №6"; ProgramInfo(); Console.WriteLine(); const int rhombusPointsQuantity = 4; Point[] rhombusPoints = new Point[rhombusPointsQuantity]; for (int i = 0; i < rhombusPointsQuantity; i++) { EnterPoint(out rhombusPoints[i], i + 1); } Figure rhombus1; try // check whether entered coordinates can be coordinates of a rhombus { rhombus1 = new Rhombus(rhombusPoints); } catch (NotARhombusException) // if exception is throws, the rhombus th formed from defined(hard-coded) coordinates { Console.WriteLine("You entered not a rhombus"); Console.WriteLine("The rhombus will be created with defined coordinates: "); Console.WriteLine("(-1, 0)\n( 0, 2)\n( 1, 0)\n( 0, -2)"); Point[] definedRhombusPoints = { new Point(-1, 0), new Point(0, 2), new Point(1, 0), new Point(0, -2) }; rhombus1 = new Rhombus(definedRhombusPoints); } Console.WriteLine("The area of your rhombus is: {0:F6}", rhombus1.GetArea()); Console.WriteLine("The perimeter of your rhombus is: {0:F6}", rhombus1.GetPerimeter()); Console.WriteLine(); double radius; bool parsed; do { Console.WriteLine("Enter the radius of the circle: "); parsed = double.TryParse(Console.ReadLine().Replace('.', ','), out radius); }while (!parsed || radius <= 0); // checking whether radius is bigger than 0 Figure circle1 = new Circle(radius); Console.WriteLine("The area of your circle is: {0:F6}", circle1.GetArea()); Console.WriteLine("The perimeter of your circle is: {0:F6}", circle1.GetPerimeter()); Console.WriteLine("\nPress ENTER to quit"); Console.Read(); }