public static void Main() { Circle circle = new Circle(5); Console.WriteLine(circle); Rectangle rectangle = new Rectangle(2, 3); Console.WriteLine(rectangle); }
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()); } }