Esempio n. 1
0
        static void Main(string[] args)
        {
            #region Sqaure
            Square square = new Square(2);

            //Printing square
            Console.WriteLine("Perimeter of sqaure");
            Console.WriteLine(square.CalculatePerimeter());
            Console.WriteLine("\nArea of sqaure");
            Console.WriteLine(square.CalculateArea());
            #endregion

            #region Rectangel

            Rectangel rectangel = new Rectangel(6, 7);

            //Printing square
            Console.WriteLine("\nPerimeter of Rectangel");
            Console.WriteLine(rectangel.CalculatePerimeter());
            Console.WriteLine("\nArea of Rectangel");
            Console.WriteLine(rectangel.CalculateArea());
            #endregion

            #region Paralleogram
            Parallelogram parallelogram = new Parallelogram(3, 5, 20);

            //Printing paralleogram
            Console.WriteLine("\nArea of parallelogram");
            Console.WriteLine(parallelogram.CalculateArea());
            #endregion

            #region Trapez
            Trapez trapez = new Trapez(10, 9, 8, 9);

            //Printing trapez
            Console.WriteLine("\nArea of trapez");
            Console.WriteLine(trapez.CalculateArea());
            Console.WriteLine("\nPerimeter of trapez");
            Console.WriteLine(trapez.CalculatePerimeter());
            #endregion

            #region Right angel triangle
            RightAngelTriangle rightAngelTriangle = new RightAngelTriangle(3, 4);

            //Printing right angel triangle
            Console.WriteLine("\nPerimeter of right angel triangle");
            Console.WriteLine(rightAngelTriangle.CalculatePerimeter());
            Console.WriteLine("\nArea of right angel triangle");
            Console.WriteLine(rightAngelTriangle.CalculateArea());
            #endregion
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            //I create the objects
            Square        square        = new Square();
            Parallelogram parallelogram = new Parallelogram();
            Trapez        trapez        = new Trapez();
            Triangle      triangle      = new Triangle();
            Rektangel     rektangel     = new Rektangel();

            //Sets site for a square
            square.SiteA = 10;

            //Sets sites and angle for a parallelogram
            parallelogram.SiteA = 3;
            parallelogram.SiteB = 5;
            parallelogram.Angle = 20;

            //sets sites for a Trapezoid
            trapez.SiteA = 10;
            trapez.SiteB = 9;
            trapez.SiteC = 8;
            trapez.SiteD = 9;

            //Sets sites for a Triangle
            triangle.SiteA = 15;
            triangle.SiteB = 10;

            //Sets sites for a Rectangle
            rektangel.SiteA = 12;
            rektangel.SiteB = 16;

            //Creates a list and adds the shapes to the list
            List <Square> shapeList = new List <Square>();

            shapeList.Add(square);
            shapeList.Add(parallelogram);
            shapeList.Add(trapez);
            shapeList.Add(triangle);

            //Prints the calculations made on the items in the list with the methods from the respective classes
            foreach (Square item in shapeList)
            {
                Console.WriteLine(item.ArealCalc());
                Console.WriteLine(item.CircCalc());
            }


            //Pauses the program so you have time to read my beautiful results.
            Console.ReadKey();
        }