static void Main(string[] args) { TwoDShape[] shapes = new TwoDShape[4]; shapes[0] = new Triangle("right", 8.0, 12.0); shapes[1] = new Rectangle(10); shapes[2] = new Rectangle(10, 4); shapes[3] = new Triangle(7.0); for (int i = 0; i < shapes.Length; i++) { Console.WriteLine("object is " + shapes[i].name); Console.WriteLine("Area is " + shapes[i].Area()); Console.WriteLine(); } }
// Construct a copy of a TwoDShape object. public TwoDShape(TwoDShape ob) { Width = ob.Width; Height = ob.Height; name = ob.name; }