Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Square example = new Square(5);

            Console.WriteLine("Area:" + example.CalculateArea());
            Console.WriteLine("Perimeter:" + example.CalculatePermimeter());

            Rectangle Box = new Rectangle(3, 5);

            Console.WriteLine("Area:" + Box.CalculateArea());
            Console.WriteLine("Perimeter:" + Box.CalculatePermimeter());

            Circle Things = new Circle(5);

            Console.WriteLine("Area:" + Things.CalculateArea());
            Console.WriteLine("Perimeter:" + Things.CalculatePermimeter());

            Ellipse AlmostCircle = new Ellipse(2, 2);

            Console.WriteLine("Area:" + AlmostCircle.CalculateArea());
            Console.WriteLine("Perimeter:" + AlmostCircle.CalculatePermimeter());

            Pentagon Government = new Pentagon(3);

            Console.WriteLine("Area:" + Government.CalculateArea());
            Console.WriteLine("Perimeter:" + Government.CalculatePermimeter());
        }
Exemplo n.º 2
0
        static void Main()
        {
            Shape circle = new Circle(5);
            Shape rect   = new Rectangle(2, 6);


            Console.WriteLine(circle.CalculateArea());
            Console.WriteLine(rect.CalculateArea());
        }
        static void Main(string[] args)
        {
            Shape rectangle = new Rectangle(5, 9);
            Shape circle    = new Circle(8);

            Console.WriteLine(circle.Draw());
            Console.WriteLine(rectangle.Draw());
            Console.WriteLine(rectangle.CalculatePerimeter());
            Console.WriteLine(circle.CalculateArea());
        }
Exemplo n.º 4
0
        public static void Main(string[] args)
        {
            Shape rectangle = new Reactangle(5, 6);
            Shape circle    = new Circle(10);

            Console.WriteLine(rectangle.CalculateArea());
            Console.WriteLine(rectangle.CalculatePerimeter());
            Console.WriteLine(circle.CalculatePerimeter());
            Console.WriteLine(circle.CalculateArea());
        }
Exemplo n.º 5
0
        public static void Main(string[] args)
        {
            Shape rect = new Rectangle(3.0, 4.0);

            Shape circle = new Circle(4.0);

            Console.WriteLine(rect.CalculateArea());

            Console.WriteLine(circle.CalculateArea());
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            Shape c = new Circle(3);
            Shape r = new Rectangle(3, 5);

            Console.WriteLine(c.CalculateArea());

            Console.WriteLine(c.Draw());
            Console.WriteLine(r.Draw());
        }
Exemplo n.º 7
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());
        }
Exemplo n.º 8
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());
        }
Exemplo n.º 9
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());
        }
Exemplo n.º 10
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());
        }
Exemplo n.º 11
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());
        }
Exemplo n.º 12
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}");
        }
Exemplo n.º 13
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());
        }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            var circle = new Circle(5);
            Console.WriteLine(circle.CalculateArea());
            Console.WriteLine(circle.CapculatePerimeter());

            var triangle = new Triangle(2, 2);
            Console.WriteLine(triangle.CalculateArea());
            Console.WriteLine(triangle.CapculatePerimeter());

            var rectangle = new Rectangle(3, 3);
            Console.WriteLine(rectangle.CalculateArea());
            Console.WriteLine(rectangle.CapculatePerimeter());
        }
Exemplo n.º 15
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());
        }
Exemplo n.º 16
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();
        }
Exemplo n.º 17
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());
        }
Exemplo n.º 18
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}");
        }
Exemplo n.º 19
0
        public static void Run()
        {
            Circle circle = new Circle(5);

            Console.WriteLine($"S of Circle is {circle.CalculateArea()}");
            Console.WriteLine($"Perimeter of Circle is {circle.CaculatePerimeter()}");
            circle.Draw();

            Ractangle ractangle = new Ractangle(10, 10);

            Console.WriteLine($"S of Ractangle is {ractangle.CalculateArea()}");
            Console.WriteLine($"Perimeter of Ractangle is {ractangle.CaculatePerimeter()}");
            ractangle.Draw();
        }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            Circle    circle = new Circle(15);
            Rectangle rect   = new Rectangle(10, 5);

            Console.WriteLine(circle.CalculateArea());
            Console.WriteLine(circle.CalculatePerimeter());
            Console.WriteLine();
            Console.WriteLine(rect.CalculateArea());
            Console.WriteLine(rect.CalculatePerimeter());
            Console.WriteLine();
            Console.WriteLine(circle.Draw());
            Console.WriteLine(rect.Draw());
        }
Exemplo n.º 21
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());
        }
Exemplo n.º 22
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();
        }
Exemplo n.º 23
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();
        }
Exemplo n.º 24
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());
        }
Exemplo n.º 25
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());
        }
Exemplo n.º 26
0
        static void Main(string[] args)
        {
            var circle = new Circle(5);

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

            var triangle = new Triangle(2, 2);

            Console.WriteLine(triangle.CalculateArea());
            Console.WriteLine(triangle.CapculatePerimeter());

            var rectangle = new Rectangle(3, 3);

            Console.WriteLine(rectangle.CalculateArea());
            Console.WriteLine(rectangle.CapculatePerimeter());
        }
Exemplo n.º 27
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);
            }
        }
Exemplo n.º 28
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);
            }
        }
Exemplo n.º 29
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!");
        }
Exemplo n.º 32
0
        public void TestCircleCalculateArea()
        {
            Circle r = new Circle(12);

            Assert.AreEqual(452.389342, Math.Round(r.CalculateArea(), 6));
        }