In C Sharp, How do I get the output to display the objects : For Example: The area of a Rectangle is: 25Not : The area of ssullivan_A2_1.cs.Program+Rectangle is: 25 static void Main(string[] args) { ////Store the objects in a Collection object (List, Array, HashSet, etc...) objects in the collection will be of type Shape Shapes[] arrayOfShapes = new Shapes[3]; arrayOfShapes[0] = new Circle(5);// arrayOfShapes[1] = new Rectangle(5, 5);// arrayOfShapes[2] = new Triangle(5, 3);// //the values used to initialize the shape, the area, and the perimeter foreach (Shapes objects in arrayOfShapes) {// use arrayOfShapes to call methods //The output should display the Object Type (Circle, Square or Triangle) //the values used to initialize the shape, the area, and the perimeter // Console.WriteLine(arrayOfShapes); // use objects to call functions Console.WriteLine("The area of " + objects + " is: " + objects.CalculateArea()); Console.WriteLine("The perimeter of this shape is: " + objects.CalculatePerimeter());// you have more than 1 print line need {} } }
In C Sharp, How do I get the output to display the objects :
For Example: The area of a Rectangle is: 25
Not : The area of ssullivan_A2_1.cs.Program+Rectangle is: 25
static void Main(string[] args)
{ ////Store the objects in a Collection object (List, Array, HashSet, etc...) objects in the collection will be of type Shape
Shapes[] arrayOfShapes = new Shapes[3];
arrayOfShapes[0] = new Circle(5);//
arrayOfShapes[1] = new Rectangle(5, 5);//
arrayOfShapes[2] = new Triangle(5, 3);//
//the values used to initialize the shape, the area, and the perimeter
foreach (Shapes objects in arrayOfShapes)
{// use arrayOfShapes to call methods
//The output should display the Object Type (Circle, Square or Triangle)
//the values used to initialize the shape, the area, and the perimeter
// Console.WriteLine(arrayOfShapes);
// use objects to call functions
Console.WriteLine("The area of " + objects + " is: " + objects.CalculateArea());
Console.WriteLine("The perimeter of this shape is: " + objects.CalculatePerimeter());// you have more than 1 print line need {}
}
}
Step by step
Solved in 2 steps