Esempio n. 1
0
        static void Main()
        {
            Circle circle = new Circle(5);
            Console.WriteLine("I am a circle. " +
                "My perimeter is {0:f2}. My surface is {1:f2}.",
                circle.CalculatePerimeter(), circle.CalculatePerimeter());

            Rectangle rect = new Rectangle(2, 3);
            Console.WriteLine("I am a rectangle. " +
                "My perimeter is {0:f2}. My surface is {1:f2}.",
                rect.CalculatePerimeter(), rect.CalculateSurface());
        }
        public static void Main()
        {
            Circle circle = new Circle(5);

            Console.WriteLine(
                "I am a circle. " +
                "My perimeter is {0:f2}. My surface is {1:f2}.",
                circle.CalculatePerimeter(),
                circle.CalculateSurface());

            Rectangle rect = new Rectangle(2, 3);

            Console.WriteLine(
                "I am a rectangle. " +
                "My perimeter is {0:f2}. My surface is {1:f2}.",
                rect.CalculatePerimeter(),
                rect.CalculateSurface());

            // Throws exceptions
            IFigure[] figures =
                {
                    circle,
                    rect,
                    new Circle(-20),
                    new Rectangle(-10, 5)
                };
        }
        public static void Main()
        {
            Circle circle = new Circle(5);

            Console.WriteLine(
                "I am a circle. " +
                "My perimeter is {0:f2}. My surface is {1:f2}.",
                circle.CalculatePerimeter(),
                circle.CalculateSurface());

            Rectangle rect = new Rectangle(2, 3);

            Console.WriteLine(
                "I am a rectangle. " +
                "My perimeter is {0:f2}. My surface is {1:f2}.",
                rect.CalculatePerimeter(),
                rect.CalculateSurface());

            // Throws exceptions
            IFigure[] figures =
            {
                circle,
                rect,
                new Circle(-20),
                new Rectangle(-10, 5)
            };
        }
 public static void Main(string[] args)
 {
     IFigure circle = new Circle(5);
     Console.WriteLine("I am a circle. " +
         "My perimeter is {0:f2}. My surface is {1:f2}.",
         circle.CalculatePerimeter(), circle.CalculateSurface());
     IFigure rect = new Rectangle(2, 3);
     Console.WriteLine("I am a rectangle. " +
         "My perimeter is {0:f2}. My surface is {1:f2}.",
         rect.CalculatePerimeter(), rect.CalculateSurface());
 }
Esempio n. 5
0
        public static void Main()
        {
            Circle circle = new Circle(5);
            Console.WriteLine("I am a circle with radius {2}. " + "\nMy perimeter is {0:f2}. My surface is {1:f2}.", circle.CalculatePerimeter(), circle.CalculateSurface(), circle.Radius);

            Console.WriteLine(new string('-', 40));

            Rectangle rect = new Rectangle(2, 3);
            Console.WriteLine("I am a rectangle with width {2} and height {3}. " + "\nMy perimeter is {0:f2}. My surface is {1:f2}.", rect.CalculatePerimeter(), rect.CalculateSurface(), rect.Width, rect.Height);

            Console.WriteLine(new string('-', 40));
        }
        static void Main()
        {
            Circle circle = new Circle(5);

            Console.WriteLine("I am a circle. " +
                              "My perimeter is {0:f2}. My surface is {1:f2}.",
                              circle.CalculatePerimeter(), circle.CalculateArea());
            Rectangle rect = new Rectangle(2, 3);

            Console.WriteLine("I am a rectangle. " +
                              "My perimeter is {0:f2}. My surface is {1:f2}.",
                              rect.CalculatePerimeter(), rect.CalculateArea());
        }
        public static void Main()
        {
            Circle circle = new Circle(5);
            var circlePerimeter = circle.CalculatePerimeter();
            var circleArea = circle.CalculateArea();

            Console.WriteLine("I am a circle. " + "My perimeter is {0:f2}. My area is {1:f2}.", circlePerimeter, circleArea);

            Rectangle rectangle = new Rectangle(2, 3);
            var rectanglePerimeter = rectangle.CalculatePerimeter();
            var rectangleArea = rectangle.CalculateArea();

            Console.WriteLine("I am a rectangle. " + "My perimeter is {0:f2}. My area is {1:f2}.", rectanglePerimeter, rectangleArea);
        }
Esempio n. 8
0
        private static void Main()
        {
            var circle = new Circle(5);

            Console.WriteLine(
                "I am a circle. My perimeter is {0:f2}. My surface is {1:f2}.",
                circle.CalculatePerimeter(),
                circle.CalculateSurface());

            var rect = new Rectangle(2, 3);

            Console.WriteLine(
                "I am a rectangle. My perimeter is {0:f2}. My surface is {1:f2}.",
                rect.CalculatePerimeter(),
                rect.CalculateSurface());
        }
        public static void Main()
        {
            var circle = new Circle(5);

            double circlePerimeter = circle.CalculatePerimeter();
            double circleSurface = circle.CalculateSurface();

            Console.WriteLine(PrintMessageCircle, circlePerimeter, circleSurface);

            var rectangle = new Rectangle(2, 3);

            double rectanglePerimeter = rectangle.CalculatePerimeter();
            double rectangleSurface = rectangle.CalculateSurface();

            Console.WriteLine(PrintMessageRectangle, rectanglePerimeter, rectangleSurface);
        }
Esempio n. 10
0
        public static void Main()
        {
            Circle circle = new Circle(5);
            var circlePerimeter = circle.CalculatePerimeter();
            var circleSurface = circle.CalculateSurface();

            var circleInformationAsString = string.Format("I am a circle. My perimeter is {0:f2}. My surface is {1:f2}.", circlePerimeter, circleSurface);
            Console.WriteLine(circleInformationAsString);

            Rectangle rectangle = new Rectangle(2, 3);
            var rectanglePerimeter = rectangle.CalculatePerimeter();
            var rectangleSurface = rectangle.CalculateSurface();

            var rectangleInformationAsString = string.Format("I am a rectangle. My perimeter is {0:f2}. My surface is {1:f2}.",
                rectanglePerimeter, rectangleSurface);
            Console.WriteLine(rectangleInformationAsString);
        }
Esempio n. 11
0
        public static void Main()
        {
            Circle circle          = new Circle(5);
            var    circlePerimeter = circle.CalculatePerimeter();
            var    circleSurface   = circle.CalculateSurface();

            var circleInformationAsString = string.Format("I am a circle. My perimeter is {0:f2}. My surface is {1:f2}.", circlePerimeter, circleSurface);

            Console.WriteLine(circleInformationAsString);

            Rectangle rectangle          = new Rectangle(2, 3);
            var       rectanglePerimeter = rectangle.CalculatePerimeter();
            var       rectangleSurface   = rectangle.CalculateSurface();

            var rectangleInformationAsString = string.Format("I am a rectangle. My perimeter is {0:f2}. My surface is {1:f2}.",
                                                             rectanglePerimeter, rectangleSurface);

            Console.WriteLine(rectangleInformationAsString);
        }
        static void Main()
        {
            var    radius = double.Parse(Console.ReadLine());
            Circle circle = new Circle(radius);

            var result = new StringBuilder();

            result.AppendFormat("I am a circle. My perimeter is {0:f2}. My surface is {1:f2}.", circle.CalculatePerimeter(), circle.CalculateSurface());

            var width  = double.Parse(Console.ReadLine());
            var height = double.Parse(Console.ReadLine());

            Rectangle rectangle = new Rectangle(width, height);

            result.AppendFormat("I am a rectangle. My perimeter is {0:f2}. My surface is {1:f2}.", rectangle.CalculatePerimeter(), rectangle.CalculateSurface());

            Console.WriteLine(result.ToString());
        }