Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Tester
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Please input the number of shapes: ");
- string input = Console.ReadLine();
- int numberOfShapes = int.Parse(input);
- Shape[] array = new Shape[numberOfShapes];
- int[] newArray = new int[numberOfShapes];
- for (int i = 0; i < numberOfShapes; i++)
- {
- Console.WriteLine("Please input the TYPE of shape {0} [c, r, t]: ", i + 1);
- string inputForType1 = Console.ReadLine();
- if (inputForType1 == "c") //use input.Equals
- {
- array[i] = new Circle();
- }
- else if (inputForType1 == "r")
- {
- array[i] = new Rectangle();
- }
- else if (inputForType1 == "t")
- {
- array[i] = new Triangle();
- }
- array[i].GetDimensions();
- ;
- }
- /*for (int i = 0; i < numberOfShapes; ++i;)
- {
- double area = array[i].GetArea();
- }*/
- Console.WriteLine("Area of shape 1 is: {0} ", newArray[0]);
- Console.WriteLine("Area of shape 2 is: {0} ", newArray[1]);
- Console.WriteLine("Area of shape 3 is: {0} ", newArray[2]);
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement