Advertisement
stefanpu

PhoneMobileTestConstructorChange

Mar 22nd, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. static void Main(string[] args)
  2.         {
  3.             GSM[] test = new GSM[2];
  4.  
  5.             Display testDisplay = new Display(12, 13);
  6.             Battery testBattery = new Battery(BatteryType.LiIon, 10, 10);
  7.  
  8.             GSM firstPhone = new GSM("c5-03", "Nokia", 350.99, "Ganio", testBattery, testDisplay);
  9.             test[0] = firstPhone;
  10.  
  11.             //Оригиналният вариант на конструктора.
  12.             //GSM secondPhone = new GSM("Galaxy S III", "Samsung", 680.99, "Didi", testBattery, testDisplay);
  13.  
  14.             //Конструктор без стойности за батерия и дисплей.
  15.             GSM secondPhone = new GSM("Galaxy S III", "Samsung", 680.99, "Didi");
  16.             test[1] = secondPhone;
  17.  
  18.          
  19.  
  20.             for (int i = 0; i < test.Length; i++)
  21.             {
  22.                 //Ето тук се хвърля изключение - "test[i]" скрито извиква своя метод "ToString()".
  23.                 Console.WriteLine(test[i]);
  24.             }
  25.  
  26.             Console.WriteLine(GSM.IPhone.ModelPhone);
  27.             Console.WriteLine(GSM.IPhone.Manifacturer);
  28.  
  29.         }
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement