Example #1
14
        static void Main()
        {
            //creates a Triangle and calculates surface
            var triangle = new Triangle(3.2, 4.5);
            var triangleSurface = triangle.CalculateSurface();

            //creates a Rectangle and calculates surface
            var rectangle = new Rectangle(4, 12.3);
            var rectangleSurface = rectangle.CalculateSurface();

            //creates a Square and calculates surface
            var square = new Square(5);
            var squareSurface = square.CalculateSurface();

            //prints shapes and surfaces
            PrintShape(triangle);
            Console.WriteLine("Surface of the triangle is: {0}", triangleSurface);
            Console.WriteLine(new string('-', 30));
            Console.WriteLine();

            PrintShape(rectangle);
            Console.WriteLine("Surface of the rectangle is: {0}", rectangleSurface);
            Console.WriteLine(new string('-', 30));
            Console.WriteLine();

            PrintShape(square);
            Console.WriteLine("Surface of the square is: {0}", squareSurface);
            Console.WriteLine(new string('-', 30));
        }
Example #2
0
        static void Main()
        {
            var triangle = new Triangle(5, 2);
            var result   = triangle.CalculateSurface();

            Console.WriteLine("Triangle surface = " + result);
            var rectangle = new Rectangle(5.4, 3);

            Console.WriteLine("Rectangle surface = " + rectangle.CalculateSurface());
            var square = new Square(5);

            Console.WriteLine("Square surface = " + square.CalculateSurface());

            Shape[] testShapes =
            {
                new Triangle(5,    2),
                new Rectangle(5.4, 3),
                new Square(5)
            };

            foreach (var item in testShapes)
            {
                Console.WriteLine(item.GetType() + " = " + item.CalculateSurface());
            }
        }
Example #3
0
 public static void Main()
 {
     Triangle triangle = new Triangle(4, 5);
     Console.WriteLine(triangle.CalculateSurface());
     var rectangle = new Rectangle(3, 5);
     Console.WriteLine(rectangle.CalculateSurface());
     var circle = new Circle(4);
     Console.WriteLine("{0:F2}", circle.CalculateSurface());
 }
Example #4
0
        static void Main(string[] args)
        {
            Triangle  tr     = new Triangle(1, 3);
            Rectangle rect   = new Rectangle(2, 2);
            Circle    circle = new Circle(3);

            Console.WriteLine(tr.CalculateSurface());
            Console.WriteLine(rect.CalculateSurface());
            Console.WriteLine(circle.CalculateSurface());
        }
Example #5
0
        static void Main()
        {
            var triangle = new Triangle(4, 3);
            var rectangle = new Rectangle(12, 10);
            var square = new Square(10);

            Console.WriteLine("The Area of Triangle is: {0}", triangle.CalculateSurface());
            Console.WriteLine("The Area of Rectangle is: {0}", rectangle.CalculateSurface());
            Console.WriteLine("The Area of Square is: {0}", square.CalculateSurface());
        }
        static void Main()
        {
            var rect = new Rectangle(12, 32.21);
            var square = new Square(12, 12);
            var tri = new Triangle(33, 12);

            Console.WriteLine(rect.CalculateSurface());
            Console.WriteLine(square.CalculateSurface());
            Console.WriteLine(tri.CalculateSurface());

            var squareCheck = new Square(12, 13);
        }
        static void Main()
        {
            var rect   = new Rectangle(12, 32.21);
            var square = new Square(12, 12);
            var tri    = new Triangle(33, 12);

            Console.WriteLine(rect.CalculateSurface());
            Console.WriteLine(square.CalculateSurface());
            Console.WriteLine(tri.CalculateSurface());


            var squareCheck = new Square(12, 13);
        }
Example #8
0
        public static void Main(string[] args)
        {
            var triangle = new Triangle(6, 7);

            Console.WriteLine(triangle.CalculateSurface());
            var rectangle = new Rectangle(7, 6);

            Console.WriteLine(rectangle.CalculateSurface());
            var square = new Square(6, 6);

            Console.WriteLine(square.CalculateSurface());
            var squareTwo = new Square(6, 7);

            Console.WriteLine(squareTwo.CalculateSurface());
        }
        static void Main()
        {
            Triangle triangle = new Triangle(2, 3);
            Rectangle rectangle = new Rectangle(2, 3);
            Square square = new Square(2);
            Console.WriteLine("Triangle area is {0}", triangle.CalculateSurface());
            Console.WriteLine("Rectangle area is {0}", rectangle.CalculateSurface());
            Console.WriteLine("Square area is {0}", square.CalculateSurface());

            //Write a program that tests the behaviour of the CalculateSurface() method
            //for different shapes (Square, Rectangle, Triangle) stored in an array

            Shape[] all = new Shape[]
            {   new Triangle (2,3),
                new Rectangle(2,3),
                new Square (3)
            };

            foreach (Shape shape in all)
            {
                Console.WriteLine("{0} is the area of the object {1}",
                    shape.CalculateSurface(), shape.GetType());
            }
        }
Example #10
0
        static void Main(string[] args)
        {
            Triangle tr = new Triangle(1, 3);
            Rectangle rect = new Rectangle(2, 2);
            Circle circle = new Circle(3);

            Console.WriteLine(tr.CalculateSurface());
            Console.WriteLine(rect.CalculateSurface());
            Console.WriteLine(circle.CalculateSurface());
        }