Ejemplo n.º 1
0
 static void Main(string[] args)
 {
     //Toy a = new Toy(color: "blue", size: 15);
     //Toy b = new Toy(12, "pink");
     //Toy c = new Toy(58, "green");
     //List<Toy> toys = new List<Toy> { a, b, c };
     //Person c1 = new Children(false);
     //Children c2 = new Children(false, toys);
     //Adults ad = new Adults(true);
     //List<Children> list = new List<Children>() { (Children)c1, c2 };
     //Adults ad2 = new Adults(true, list);
     //Console.WriteLine(ad2.ToString());
     //Console.WriteLine(c1.ToString());
     //Console.WriteLine(c2.ToString());
     // Console.WriteLine(a.ToString());
     Point a = new Point(2, 2);
     Rectangle b = new Rectangle(3,2,a);
     Square d = new Square(2,a);
     Rectangle c = new Square(3,a);
     Ellipse e = new Ellipse(3, 2, a);
     Circle f = new Circle(3, a);
     Triangle t = new Triangle(3, 4, 5);
     Console.WriteLine(t.ToString());
     Console.WriteLine(t.GetArea());
     Console.WriteLine(t.GetPerimeter());
     IMovable x = new Square(2,a);
     Console.WriteLine(x.ToString());
     x.Move(3, 3);
     Console.WriteLine(x.ToString());
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Shape[] Array = new Shape[100];
            Array[0] = new Triangle(1, 1, Math.Sqrt(2));
            Array[1] = new Rectangle(5, 6.5);
            Array[2] = new Circle(8);

            for (int i = 0; Array[i] != null; i++)
                Console.WriteLine(Array[i].calcArea());

            Console.ReadLine();
        }
Ejemplo n.º 3
0
        static void Main()
        {
            Shape[] container = new Shape[3];
            container[0] = new Triangle(2, 5);
            container[1] = new Rectangle(15, 2);
            container[2] = new Circle(15, 2);

            foreach (var shape in container)
            {
                shape.CalculateSurface();
            }
        }
Ejemplo n.º 4
0
 static void Main(string[] args)
 {
     Shape[] arr = new Shape[100];
     Round shape1 = new Round(10);
     Triangle shape2 = new Triangle(8, 6, 4);
     Rectangle shape3 = new Rectangle(3, 5);
     arr[0] = shape1;
     arr[1] = shape2;
     arr[2] = shape3;
     for (int i = 0; arr[i] != null; i++)
         Console.WriteLine(arr[i].Area());
     Console.ReadLine();
 }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            Shape[] ArrayObject = new Shape[3];

            Shape triangle = new Triangle(12, 12, 12);
            Shape circle = new Circle(12);
            Shape rectangle = new Rectangle(12, 12);

            ArrayObject[0] = triangle;
            ArrayObject[1] = circle;
            ArrayObject[2] = rectangle;

            for (int count = 0; count <= 2; count++)
            {
                Console.WriteLine(ArrayObject[count].Area());
            }

            Console.ReadLine();
        }
        static void Main()
        {
            Rectangle rect2 = new Rectangle(21.5,10.3);
            Triangle tri2 = new Triangle(12.3, 15.4);
            Circle circ2 = new Circle(4.16);
            Rectangle rect1 = new Rectangle(10.4,5.3);
            Triangle tri1 = new Triangle(7.6,4.6);
            Circle  circ1 = new Circle(1.5);

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

            shapes.Add(rect2);
            shapes.Add(tri2);
            shapes.Add(circ2);
            shapes.Add(rect1);
            shapes.Add(tri1);
            shapes.Add(circ1);

            var orderedByAreas = shapes.OrderBy(s => s.CalculateSurface());

            Print(orderedByAreas);
        }
Ejemplo n.º 7
0
 public void ShouldReturnAreaOfTheRectangle(double height, double width, double expectedResult)
 {
     var rectangle = new Rectangle(height, width);
     var actualresult = rectangle.GetArea();
     Assert.That(actualresult, Is.EqualTo(expectedResult));
 }
Ejemplo n.º 8
0
 public void ShouldNotHaveNegativeWidthAndHeight()
 {
     var rectangle = new Rectangle(-1, -3);
 }
Ejemplo n.º 9
0
 public void ShouldNotHaveNegativeWidth()
 {
     var rectangle = new Rectangle(10, -2);
 }
Ejemplo n.º 10
0
 public void ShouldNotHaveNegativeHeight()
 {
     var rectangle = new Rectangle(-10, 2);
 }
Ejemplo n.º 11
0
 public double ShouldCalculatePerimeter(double height, double width)
 {
     var rectangle = new Rectangle(height, width);
     return rectangle.GetPerimeter();
 }