Beispiel #1
0
        static void Main(string[] args)
        {
            Rect rect = new Rect(new Fdata()
            {
                x0 = 1, y0 = 1, a = 3, b = 5
            });

            rect.Move(2, 1);
            rect.PrintInfo();
            Console.WriteLine(rect.Area());

            RightTriangle rt = new RightTriangle(new Fdata()
            {
                x0 = -1, y0 = -3, a = 1, b = 4
            });

            rt.Move(1, 1);
            rt.PrintInfo();
            Console.WriteLine(rt.Area());

            //Ваш код!
            Circle c = new Circle(new Fdata()
            {
                x0 = 1, y0 = 1, a = 1
            });

            c.Move(-2, 5);

            Shape newC = (Shape)c;

            newC.PrintInfo();
            Console.WriteLine(c.Area());

            Console.ReadLine();

            object[] data = { rect, rt, c };

            Print(data);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Shape square        = new Square(4);
            Shape rectangle     = new Rectangle(3, 4.5);
            Shape parallelogram = new Parallelogram(3, 5, 58);
            Shape trapezoid     = new Trapezoid(10, 9, 8);
            Shape rightTriangle = new RightTriangle(6, 8);

            List <Shape> shapes = new List <Shape>();

            shapes.Add(square);
            shapes.Add(rectangle);
            shapes.Add(parallelogram);
            shapes.Add(trapezoid);
            shapes.Add(rightTriangle);

            foreach (Shape item in shapes)
            {
                Console.WriteLine(item.GetType().Name);
                Console.WriteLine("Area: " + item.CalculateArea() + "\n"
                                  + "Circumference: " + item.CalculateCircumference() + "\n");
            }
            Console.ReadLine();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Rectangle rect         = new Rectangle(5, 10);
            var       rectPerimetr = rect.GetPerimetr();
            var       rectArea     = rect.GetArea();

            Console.WriteLine($"Rectangle Area: {rectArea} \n" +
                              $"Recatngle Perimetr: {rectPerimetr}");
            Console.WriteLine();


            Rectangle rect2          = new Square(2, 2);
            var       squarePerimetr = rect2.GetPerimetr();
            var       squareArea     = rect2.GetArea();

            Console.WriteLine($"Square Area: {squareArea} \n" +
                              $"Square Perimetr: {squarePerimetr}");
            Console.WriteLine();

            Circle circle = new Circle();

            circle.Radius = 5.63;
            var circlePerimetr = circle.GetPerimetr();
            var circleArea     = circle.GetArea();

            Console.WriteLine($"Circle Area: {circleArea} \n" +
                              $"Circle Perimetr: {circlePerimetr}");
            Console.WriteLine();

            Ellipse ellipse         = new Ellipse(12.1, 17.8);
            var     ellipsePerimetr = ellipse.GetPerimetr();
            var     ellipseArea     = ellipse.GetArea();

            Console.WriteLine($"Ellipse Area: {ellipseArea} \n" +
                              $"Ellipse Perimetr: {ellipsePerimetr}");
            Console.WriteLine();

            Triangle triangle = new Triangle();

            triangle.Height = 14;
            triangle.Side_A = 78;
            triangle.Side_B = 45;
            triangle.Side_C = 45;
            var trianglePerimetr = triangle.GetPerimetr();
            var triangleArea     = triangle.GetArea();

            Console.WriteLine($"Triangle Area: {triangleArea} \n" +
                              $"Triangle Perimetr: {trianglePerimetr}");
            Console.WriteLine();

            Triangle rightTriangle         = new RightTriangle(14, 15, 20.5);
            var      rightTrianglePerimetr = rightTriangle.GetPerimetr();
            var      rightTriangleArea     = rightTriangle.GetArea();

            Console.WriteLine($"Right Triangle Area: {rightTriangleArea} \n" +
                              $"Right Triangle Perimetr: {rightTrianglePerimetr}");
            Console.WriteLine();



            Console.ReadLine();
        }
 public void WrongTriangleDueAccuracy()
 {
     var t = new RightTriangle(10, 10, 14.14213562373095);
 }
 public void WrongSquare()
 {
     var t = new RightTriangle(534, 712, 890);
     Assert.AreEqual(190105, t.GetSquare());
 }
 public void WrongParam()
 {
     var t = new RightTriangle(10, 10, 15);
 }
 public void TestSquare2()
 {
     var t = new RightTriangle(534, 712, 890);
     Assert.AreEqual(190104, t.GetSquare());
 }
 public void TestSquare1()
 {
     var t = new RightTriangle(3, 4, 5);
     Assert.AreEqual(6, t.GetSquare());
 }