Advertisement
solidsnake

C#MasTamangHomework3

Apr 28th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. class Tester
  2. {
  3. static void Main(string[] args)
  4. {
  5. Console.WriteLine("Please input the number of shapes: ");
  6. string input = Console.ReadLine();
  7. int numberOfShapes = int.Parse(input);
  8.  
  9. Shape[] array = new Shape[numberOfShapes];
  10.  
  11. int[] newArray = new int[numberOfShapes];
  12.  
  13. for (int i = 0; i < numberOfShapes; i++)
  14. {
  15. Console.WriteLine("Please input the TYPE of shape {0} [c, r, t]: ", i + 1);
  16. string inputForType1 = Console.ReadLine();
  17. if (inputForType1 == "c") //use input.Equals
  18. {
  19. array[i] = new Circle();
  20. }
  21.  
  22. else if (inputForType1 == "r")
  23. {
  24. array[i] = new Rectangle();
  25.  
  26. }
  27. else if (inputForType1 == "t")
  28. {
  29. array[i] = new Triangle();
  30.  
  31. }
  32. array[i].GetDimensions();
  33. ;
  34. }
  35. /*for (int i = 0; i < numberOfShapes; ++i;)
  36. {
  37. double area = array[i].GetArea();
  38. }*/
  39.  
  40. Console.WriteLine("Area of shape 1 is: {0} ", newArray[0]);
  41. Console.WriteLine("Area of shape 2 is: {0} ", newArray[1]);
  42. Console.WriteLine("Area of shape 3 is: {0} ", newArray[2]);
  43.  
  44. Console.ReadKey();
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement