public void Should_calculate_circumference_for_rectangle()
 {
     Rectangle rect = new Rectangle();
     rect.A = 3;
     rect.B = 4;
     Assert.That(rect.Circumference(), Is.EqualTo(14));
 }
Exemple #2
0
        public static void Main()
        {
            Circle circle = new Circle(5);
            Console.WriteLine(circle);

            Rectangle rectangle = new Rectangle(2, 3);
            Console.WriteLine(rectangle);
        }
 public void ShouldTotalCircumferenceCalculator_return_correct_sum()
 {
     IShape square = new Square { A = 4 };
     IShape rect = new Rectangle { A = 4, B = 5 };
     TotalCircumferenceCalculator calculator = new TotalCircumferenceCalculator();
     calculator.Add(square);
     calculator.Add(rect);
     Assert.That(calculator.GetTotal(), Is.EqualTo(square.Circumference() + rect.Circumference()));
 }
Exemple #4
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.CalcPerimeter(), circle.CalcSurface());

            Rectangle rect = new Rectangle(2, 3.5);
            Console.WriteLine("I am a rectangle. " +
                "My perimeter is {0:f2}. My surface is {1:f2}.",
                rect.CalcPerimeter(), rect.CalcSurface());
        }
        /// <summary>
        /// Main method for the program
        /// </summary>
        public static void Main()
        {
            List<Figure> figures = new List<Figure>();
            
            Figure circle = new Circle(5);
            figures.Add(circle);
            Figure rect = new Rectangle(2, 3);
            figures.Add(rect);
            Figure baseCircle = new Circle(1);
            figures.Add(baseCircle);
            Figure square = new Rectangle(2);
            figures.Add(square);

            foreach (var figure in figures)
            {
                Console.WriteLine(
                    "I am a {0}. My perimeter is {1:f2}. My surface is {2:f2}.",
                    figure.GetType().Name,
                    figure.CalcPerimeter(),
                    figure.CalcSurface());
            }
        }
 int CalculateCircumferenceForRectangle(Rectangle rect)
 {
     rect.A = 4;
     rect.B = 5;
     return rect.Circumference();
 }