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

            Rectangle rectangle = new Rectangle(2, 3);
            Console.WriteLine(rectangle);
        }
예제 #3
0
 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()));
 }
예제 #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());
            }
        }
예제 #6
0
 int CalculateCircumferenceForRectangle(Rectangle rect)
 {
     rect.A = 4;
     rect.B = 5;
     return rect.Circumference();
 }