Ejemplo n.º 1
0
        public static void Run()
        {
            // get a circle
            Console.WriteLine("Enter circle's radius:");
            var    radius = double.Parse(Console.ReadLine());
            Circle circle = new Circle(radius);

            // get a rectangle
            Console.WriteLine("Enter rectangle's length:");
            var height = double.Parse(Console.ReadLine());

            Console.WriteLine("Enter rectangle's width:");
            var       width = double.Parse(Console.ReadLine());
            Rectangle rect  = new Rectangle(height, width);

            // Circle
            circle.Draw();
            Console.WriteLine($"Circle perimeter: {circle.CalculatePerimeter()}");
            Console.WriteLine($"Circle area: {circle.CalculateArea()}");

            // Rectangle
            rect.Draw();
            Console.WriteLine($"Rectangle perimeter:{rect.CalculatePerimeter()}");
            Console.WriteLine($"Rectangle area: {rect.CalculateArea()}");

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Shape shape  = new Rectangle(3.5, 12);
            Shape shape1 = new Circle(1);

            Console.WriteLine($"Perimeter = {shape.CalculatePerimeter():f2}; \nArea = {shape.CalculateArea():f2}; \n{shape.Draw()}");
            Console.WriteLine($"Perimeter = {shape1.CalculatePerimeter():f2}; \nArea = {shape1.CalculateArea():f2}; \n{shape1.Draw()}");
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Shape circle    = new Circle(5.5);
            Shape rectangle = new Rectangle(5.5, 5.5);

            Console.WriteLine(circle.CalculatePerimeter());
            Console.WriteLine(rectangle.CalculateArea());
        }
Ejemplo n.º 4
0
        static void Main()
        {
            Shape circle    = new Circle(3.5);
            Shape rectangle = new Rectangle(10, 7.5);

            Console.Write(rectangle.Draw());
            Console.WriteLine($"{rectangle.CalculateArea():F2}");
            Console.WriteLine($"{rectangle.CalculatePerimeter():F2}");

            Console.WriteLine(circle.Draw());
            Console.WriteLine($"{circle.CalculateArea():F2}");
            Console.WriteLine($"{circle.CalculatePerimeter():F2}");
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            Circle    circle    = new Circle(8);
            Rectangle rectangle = new Rectangle(12, 8);

            Console.WriteLine(circle.CalculateArea());
            Console.WriteLine(circle.CalculatePerimeter());
            Console.WriteLine(circle.Draw());

            Console.WriteLine(rectangle.CalculateArea());
            Console.WriteLine(rectangle.CalculatePerimeter());
            Console.WriteLine(rectangle.Draw());
        }
Ejemplo n.º 6
0
        public static void Main(string[] args)
        {
            IShape rectangle = new Rectangle(4.5, 2.9);
            IShape circle    = new Circle(8.2);

            Console.WriteLine(rectangle.Draw());
            Console.WriteLine(rectangle.CalculateArea());
            Console.WriteLine(rectangle.CalculatePerimeter());

            Console.WriteLine(circle.Draw());
            Console.WriteLine(circle.CalculateArea());
            Console.WriteLine(circle.CalculatePerimeter());
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            Rectangle rec = new Rectangle(3, 4);

            Console.WriteLine(rec.CalculateArea());
            Console.WriteLine(rec.CalculatePerimeter());
            Console.WriteLine(rec.Draw());
            Circle circle = new Circle(2);

            Console.WriteLine(circle.CalculateArea());
            Console.WriteLine(circle.CalculatePerimeter());
            Console.WriteLine(circle.Draw());
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            Shape shape = new Rectangle(2, 2);

            Console.WriteLine(shape.CalculateArea());
            Console.WriteLine(shape.CalculatePerimeter());
            Console.WriteLine(shape.Draw());

            shape = new Circle(4);
            Console.WriteLine(shape.CalculateArea());
            Console.WriteLine(shape.CalculatePerimeter());
            Console.WriteLine(shape.Draw());
        }
Ejemplo n.º 9
0
        public void Run()
        {
            Shape rectangle = new Rectangle(5, 10);
            Shape circle    = new Circle(20);

            Console.WriteLine(rectangle.CalculateArea());
            Console.WriteLine(rectangle.CalculatePerimeter());
            Console.WriteLine(rectangle.Draw());

            Console.WriteLine(circle.CalculateArea());
            Console.WriteLine(circle.CalculatePerimeter());
            Console.WriteLine(circle.Draw());
        }
Ejemplo n.º 10
0
        public static void Main()
        {
            Shape rectangle = new Rectangle(2.2, 3.5);
            Shape circle    = new Circle(2.1);

            Console.WriteLine(rectangle.CalculateArea());
            Console.WriteLine(rectangle.CalculatePerimeter());
            Console.WriteLine(rectangle.Draw());

            Console.WriteLine(circle.CalculateArea());
            Console.WriteLine(circle.CalculatePerimeter());
            Console.WriteLine(circle.Draw());
        }
Ejemplo n.º 11
0
        public static void Main(string[] args)
        {
            var circle    = new Circle(10);
            var rectangle = new Rectangle(3.5, 2.6);

            Console.WriteLine(circle.CalculateArea());
            Console.WriteLine(circle.CalculatePerimeter());
            Console.WriteLine(circle.Draw());

            Console.WriteLine(rectangle.CalculateArea());
            Console.WriteLine(rectangle.CalculatePerimeter());
            Console.WriteLine(rectangle.Draw());
        }
Ejemplo n.º 12
0
        public static void Main()
        {
            Shape shape = new Circle(3);

            Console.WriteLine(shape.Draw());
            Console.WriteLine(shape.CalculateArea());
            Console.WriteLine(shape.CalculatePerimeter());

            Shape shape2 = new Rectangle(2, 3);

            Console.WriteLine(shape2.Draw());
            Console.WriteLine(shape2.CalculateArea());
            Console.WriteLine(shape2.CalculatePerimeter());
        }
Ejemplo n.º 13
0
        public static void Main()
        {
            Rectangle rectangle = new Rectangle(0, 0);
            Circle    circle    = new Circle(0);

            Console.WriteLine("Rectangle result:");
            Console.WriteLine(rectangle.CalculatePerimeter());
            Console.WriteLine(rectangle.CalculateArea());
            Console.WriteLine(rectangle.Draw());
            Console.WriteLine("Circle result:");
            Console.WriteLine(circle.CalculatePerimeter());
            Console.WriteLine(circle.CalculateArea());
            Console.WriteLine(circle.Draw());
        }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            Circle circle = new Circle(5);

            Console.WriteLine($"{circle.CalculateArea():f2}");
            Console.WriteLine($"{circle.CalculatePerimeter():f2}");
            Console.WriteLine($"{circle.Draw():f2}");

            Rectangle rectangle = new Rectangle(4, 6);

            Console.WriteLine(rectangle.CalculateArea());
            Console.WriteLine(rectangle.CalculatePerimeter());
            Console.WriteLine(rectangle.Draw());
        }
Ejemplo n.º 15
0
        public static void Main()
        {
            var circle    = new Circle(6);
            var rectangle = new Rectangle(4, 5);

            Console.WriteLine(circle.CalculateArea());
            Console.WriteLine(circle.CalculatePerimeter());

            Console.WriteLine(rectangle.CalculateArea());
            Console.WriteLine(rectangle.CalculatePerimeter());

            circle.Draw();
            rectangle.Draw();
        }
Ejemplo n.º 16
0
        static void Main()
        {
            Shape circle = new Circle(3.0);

            Console.WriteLine(circle.Draw());
            Console.WriteLine($"Area = {circle.CalculateArea():f2}");
            Console.WriteLine($"Perimeter = {circle.CalculatePerimeter():f2}");

            Shape rect = new Rectangle(2.3, 3.0);

            Console.WriteLine(rect.Draw());
            Console.WriteLine($"Area = {rect.CalculateArea():f2}");
            Console.WriteLine($"Perimeter = {rect.CalculatePerimeter():f2}");
        }
Ejemplo n.º 17
0
        static void Main(string[] args)
        {
            var       radius = int.Parse(Console.ReadLine());
            Circle    circle = new Circle(radius);
            var       width  = int.Parse(Console.ReadLine());
            var       height = int.Parse(Console.ReadLine());
            Rectangle rect   = new Rectangle(width, height);

            Console.WriteLine(rect.Draw());
            Console.WriteLine(circle.Draw());
            Console.WriteLine(circle.CalculateArea());
            Console.WriteLine(circle.CalculatePerimeter());
            Console.WriteLine(rect.CalculateArea());
            Console.WriteLine(rect.CalculatePerimeter());
        }
Ejemplo n.º 18
0
        static void Main()
        {
            Shape rectangle = new Rectangle(4, 9);
            Shape circle    = new Circle(20);

            Console.WriteLine($"Rectangle perimeter: {rectangle.CalculatePerimeter():0.00}");
            Console.WriteLine($"Rectangle area: {rectangle.CalculateArea():0.00}");
            Console.WriteLine(Environment.NewLine + rectangle.Draw());

            Console.WriteLine($"Circle perimeter: {circle.CalculatePerimeter():0.00}");
            Console.WriteLine($"Circle area: {circle.CalculateArea():0.00}");
            Console.WriteLine(Environment.NewLine + circle.Draw());

            Console.ReadKey();
        }
Ejemplo n.º 19
0
        public static void Main()
        {
            double height = double.Parse(Console.ReadLine());
            double width  = double.Parse(Console.ReadLine());
            double radius = double.Parse(Console.ReadLine());

            Shape circle    = new Circle(radius);
            Shape rectangle = new Rectangle(height, width);

            Console.WriteLine(circle.CalculateArea());
            Console.WriteLine(circle.CalculatePerimeter());
            Console.WriteLine(rectangle.CalculateArea());
            Console.WriteLine(rectangle.CalculatePerimeter());
            Console.WriteLine(circle.Draw());
            Console.WriteLine(rectangle.Draw());
        }
Ejemplo n.º 20
0
        static void Main(string[] args)
        {
            Circle circle = new Circle(3);

            Console.WriteLine(circle.Draw());

            double perCir = circle.CalculatePerimeter();

            Console.WriteLine("Perimeter of Circle : " + perCir);


            Rectangle rectangle = new Rectangle(6, 2);

            Console.WriteLine(rectangle.Draw());

            double perRect = rectangle.CalculatePerimeter();

            Console.WriteLine("Perimeter of Rectangle : " + perRect);
        }
Ejemplo n.º 21
0
        static void Main(string[] args)
        {
            try
            {
                Shape circle = new Circle(4.1);
                Console.WriteLine(circle.CalculateArea());
                Console.WriteLine(circle.CalculatePerimeter());
                Console.WriteLine(circle.Draw());

                Shape react = new Rectangle(3.2, 4);
                Console.WriteLine(react.CalculateArea());
                Console.WriteLine(react.CalculatePerimeter());
                Console.WriteLine(react.Draw());
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 22
0
        static void Main(string[] args)
        {
            Shape rectangle = new Rectangle(5, 6);

            Console.WriteLine("Rectangle:");
            Console.WriteLine(rectangle.CalculateArea());
            Console.WriteLine(rectangle.CalculatePerimeter());
            Console.WriteLine();
            rectangle.Draw();

            Console.WriteLine();

            Shape circle = new Circle(7);

            Console.WriteLine("Circle:");
            Console.WriteLine(circle.CalculateArea());
            Console.WriteLine(circle.CalculatePerimeter());
            Console.WriteLine();
            circle.Draw();
        }
Ejemplo n.º 23
0
        public static void Main(string[] args)
        {
            try
            {
                Shape circle    = new Circle(2.5);
                Shape rectangle = new Rectangle(6, 3);

                Console.WriteLine(circle.CalculateArea());
                Console.WriteLine(circle.CalculatePerimeter());
                Console.WriteLine(circle.Draw());

                Console.WriteLine(rectangle.CalculateArea());
                Console.WriteLine(rectangle.CalculatePerimeter());
                Console.WriteLine(rectangle.Draw());
            }
            catch (ArgumentException exception)
            {
                Console.WriteLine(exception.Message);
            }
        }
Ejemplo n.º 24
0
        static void Main(string[] args)
        {
            Rectangle r = new Rectangle(3f, 4f);

            //Rectangle r = new Rectangle();
            //r.get();
            Console.WriteLine("Perimeter of rectangle is:" + r.CalculatePerimeter());

            Console.WriteLine("Area of rectangle :" + r.CalculateArea());
            Console.WriteLine(r.Draw());
            Console.WriteLine();
            Circle c = new Circle(5f);

            //Circle c = new Circle();
            //c.get();
            Console.WriteLine("Perimeter of circle is:" + c.CalculatePerimeter());

            Console.WriteLine("Area of circle :" + c.CalculateArea());
            Console.WriteLine(c.Draw());
            Console.ReadLine();
        }
        public static void Main()
        {
            try
            {
                Shape rectangle = new Rectangle(5.25, 6.5);
                Shape cirle     = new Circle(3.25);

                Console.WriteLine(rectangle.CalculateArea());
                Console.WriteLine(rectangle.CalculatePerimeter());

                Console.WriteLine(cirle.CalculateArea());
                Console.WriteLine(cirle.CalculatePerimeter());
            }
            catch (InvalidSideException ise)
            {
                Console.WriteLine(ise.Message);
            }
            catch (InvalidRadiusException ire)
            {
                Console.WriteLine(ire.Message);
            }
        }
        static void Main(string[] args)
        {
            double[] data = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries).Select(double.Parse).ToArray();

            try
            {
                Shape curentShape = null;

                switch (data.Length)
                {
                case 2:
                    curentShape = new Rectangle(data[0], data[1]);     // data[0] -> height, data[1] -> width
                    break;

                case 1:
                    curentShape = new Circle(data[0]);     // data[0] -> radius
                    break;

                default:
                    Console.WriteLine("Too many data!");
                    break;
                }

                if (curentShape != null)
                {
                    Console.WriteLine($"Area: {curentShape.CalculateArea()}");
                    Console.WriteLine($"Perimeter: {curentShape.CalculatePerimeter()}");
                    curentShape.Draw();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }


            //Console.WriteLine("Hello World!");
        }
Ejemplo n.º 27
0
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();

                if (input == "c")
                {
                    Shape circle = new Circle(5);
                    Console.WriteLine(circle.CalculateArea());
                    Console.WriteLine(circle.CalculatePerimeter());
                    Console.WriteLine(circle.Draw());
                }

                else if (input == "r")
                {
                    Shape rec = new Rectangle(4, 60);
                    Console.WriteLine(rec.CalculateArea());
                    Console.WriteLine(rec.CalculatePerimeter());
                    Console.WriteLine(rec.Draw());
                }
            }
        }
Ejemplo n.º 28
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            Circle    circle    = new Circle(5);
            Rectangle rectangle = new Rectangle(4, 6);
            Rectangle square    = new Rectangle(5);

            circle.CalculateArea();
            circle.CalculatePerimeter();
            Console.WriteLine(circle.Area);
            Console.WriteLine(circle.Perimeter);

            rectangle.CalculateArea();
            rectangle.CalculatePerimeter();
            Console.WriteLine(rectangle.Area);
            Console.WriteLine(rectangle.Perimeter);

            square.CalculateArea();
            square.CalculatePerimeter();
            Console.WriteLine(square.Area);
            Console.WriteLine(square.Perimeter);
        }
Ejemplo n.º 29
0
        static void Main(string[] args)
        {
            Rectangle rectangle = new Rectangle(21.5, 15.9);

            Console.WriteLine(rectangle.Draw());
            Console.WriteLine("RectangleArea\n" + rectangle.CalculateArea() + "\nRectanglePerimeter\n" + rectangle.CalculatePerimeter());
            Console.WriteLine("************************************");
            Circle circle = new Circle(8.1);

            Console.WriteLine(circle.Draw());
            Console.WriteLine("CircleArea\n" + circle.CalculateArea() + "\nCirclePerimeter\n" + circle.CalculatePerimeter());

            Console.ReadLine();
        }