public static void ExampleCode5()
        {
            IShape shape1 = new Rectangle(10.0F, 20.3F);
            IShape shape2 = new Rectangle(5.0F, 17.3F);

            Console.WriteLine("Area of the Rectangle-1 is {0} ", shape1.CalculateArea());
            Console.WriteLine("Area of the Rectangle-2 is {0} ", shape2.CalculateArea());

            Rectangle shape3 = (Rectangle)shape1 + (Rectangle)shape2;

            Console.WriteLine("Area of the Rectangle-3 is {0} ", shape3.CalculateArea());

            string result = shape3.Process <string>("list");

            int out1 = shape1.Display <int>(1);
            int out2 = shape2.Display <int>(2);
        }
        static void Main(string[] args)
        {
            // declaring an object
            Rectangle r = new Rectangle();

            // user inputs length of the rectangle
            Console.Write("Enter length of the rectangle: ");
            double lengthR = double.Parse(Console.ReadLine());

            // user inputs width of the rectangle
            Console.Write("Enter width of the rectangle: ");
            double widthR = double.Parse(Console.ReadLine());

            r.AcceptDetails(lengthR, widthR); // calling AcceptDetails() method
            r.Display();                      // calling Display() method
            Console.Read();                   // pausing program to read information
        }
Esempio n. 3
0
        static void Run()
        {
            Rectangle r = new Rectangle();

            r.AcceptParameters();
            r.Display();
            Console.ReadLine();

            Triangle t = new Triangle();

            t.AcceptParameters();
            t.Display();
            Console.ReadLine();

            Circle c = new Circle();

            c.AcceptParameters();
            c.Display();
            Console.ReadLine();
        }