public static void Test() { GSM[] gsms = new GSM[3]; gsms[0] = new GSM("Lumia 720", "Nokia", 100, "Pesho", 4.3, 16000000, "Samsung", 100, 100, Battery.BatteryType.NiCd); gsms[1] = new GSM("Lumia 930", "Nokia", 600, "Pesho", 5, 16000000, "Samsung", 200, 300, Battery.BatteryType.NiCd); gsms[2] = new GSM("Iphone 6", "Apple", 100, "Gosho", 5.5, 16000000, "Apple", 100, 100, Battery.BatteryType.LiIon); for (int i = 0; i < gsms.Length; i++) { Console.WriteLine(gsms[i]); } Console.WriteLine("Iphone 4 static informarmation: " + GSM.IPhone4s); }
//Method public void DisplayInfo() { var array = new GSM[] { new GSM("iPhone", "Apple", 1500, "David", new Battery("Sony", 2, 15, BatteryType.NiCd), new Display(5.5, 256)), new GSM("Galaxy", "Samsung", 1000, "John", new Battery("Philips", 4, 11, BatteryType.LiIon), new Display(3.5, 3500)), new GSM("C9", "Alcatel", 1500, "Matt", new Battery("Duracell", 13, 25, BatteryType.NiMH), new Display(4, 1500)) }; for (int i = 0; i < array.Length; i++) { Console.WriteLine(array[i]); } Console.WriteLine(GSM.IPhone4S); }
//Method public void TestCallHistory() { var phone = new GSM("iPhone", "Apple", 1500, "Rosi", new Battery("Sony", 2, 15, BatteryType.NiCd), new Display(5.5, 256)); phone.AddCall(new Call(new DateTime(2016, 6, 10, 10, 43, 25), "+359 88 6295 197", 30)); phone.AddCall(new Call(new DateTime(2016, 6, 10, 8, 35, 12), "+359 88 6295 197", 12)); phone.AddCall(new Call(new DateTime(2016, 6, 10, 5, 55, 11), "+359 88 6295 197", 125)); Console.WriteLine(phone.CallHistoryInformation()); Console.WriteLine("Total price: {0:C}", phone.TotalPrice(0.37m)); phone.RemoveLongestCall(); Console.WriteLine("Total price: {0:C}", phone.TotalPrice(0.37m)); phone.ClearCalls(); Console.WriteLine(phone.CallHistoryInformation()); }
static public void Test() { GSM gsm = new GSM("Lumia 720", "Nokia", 100, "Pesho", 4.3, 16000000, "Nokia", 100, 100, Battery.BatteryType.LiIon); gsm.AddCall(DateTime.Now, "+359886554433", 60); gsm.AddCall(DateTime.Now, "+359886114433", 6); gsm.AddCall(DateTime.Now, "+359886224433", 12); gsm.AddCall(DateTime.Now, "+359886111111", 187); gsm.AddCall(DateTime.Now, "+359886222222", 786); Console.WriteLine("Calls:"); foreach (var call in gsm.CallHistory) { Console.WriteLine("{0}, {1}, {2} seconds", call.DateTimeValue, call.Number, call.Duration); } Console.WriteLine(); Console.WriteLine("Total price {0}", gsm.CalculateTotalCallsPrice(0.37)); var index = gsm.CallHistory.Aggregate((i1, i2) => i1.Duration > i2.Duration ? i1 : i2); gsm.RemoveCall(index); Console.WriteLine("Calls:"); foreach (var call in gsm.CallHistory) { Console.WriteLine("{0}, {1}, {2} seconds", call.DateTimeValue, call.Number, call.Duration); } Console.WriteLine(); Console.WriteLine("Total price {0}", gsm.CalculateTotalCallsPrice(0.37)); gsm.ClearCalls(); }