public static void Test() { GSM Lenovo = new GSM("S500", "IBM", 765, "Pero", new Battery("Lenovo", 500, 400, BatteryType.NiMH), new Display(10, 2000000)); Lenovo.AddCall(new Call(new DateTime(2017, 08, 22, 08, 25, 45), "359898738350", 123)); Lenovo.AddCall(new Call(new DateTime(2017, 07, 15, 12, 20, 12), "359898738215", 45)); Lenovo.AddCall(new Call(new DateTime(2017, 11, 02, 10, 15, 33), "359894624788", 300)); foreach (Call call in Lenovo.CallHistory) { Console.WriteLine(call); } Console.WriteLine("{0:F2}", Lenovo.PhoneBill()); Call longestCall = null; for (int i = 0; i < Lenovo.CallHistory.Count; i++) { for (int j = 0; j < Lenovo.CallHistory.Count; j++) { if (Lenovo.CallHistory[i].DurationInSeconds >= Lenovo.CallHistory[j].DurationInSeconds) { longestCall = Lenovo.CallHistory[i]; } } } Lenovo.RemoveCall(longestCall); Console.WriteLine("{0:F2}", Lenovo.PhoneBill()); Lenovo.ClearCallHistory(); foreach (Call call in Lenovo.CallHistory) { Console.WriteLine(call); } }
static void Main() { //Task 7 GSMtest.GSMTest(); //Task 12 //Create an instance of the GSM class. var battery = new Battery(BatteryType.LiIon, 100, 10); var display = new Display(2.5m, 5000); var gsm = new GSM("3310", "NOKIA", 25.5m, "Pencho", battery, display); //Add few calls. var call1 = new Calls("06/12/2016", "13:41", "0888 12 34 56", 10); var call2 = new Calls("06/12/2016", "15:41", "0888 12 34 56", 20); var call3 = new Calls("06/12/2016", "17:41", "0888 12 34 56", 30); gsm.AddCalls(call1); gsm.AddCalls(call2); gsm.AddCalls(call3); //Display the information about the calls. Console.WriteLine(call1); Console.WriteLine(call2); Console.WriteLine(call3); //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history. Console.WriteLine($"Total calls price = {gsm.CalculateCallPrice(0.37m)}"); //Remove the longest call from the history and calculate the total price again. Calls longest = gsm.CallsHistory[0]; foreach (var call in gsm.CallsHistory) { if (call.CallDuration > longest.CallDuration) { longest = call; } } gsm.DeleteCalls(longest); Console.WriteLine($"Total calls price after the longest call is removed = {gsm.CalculateCallPrice(0.37m)}"); //Finally clear the call history and print it. gsm.ClearCallHistory(); Console.WriteLine($"Calls history cleared"); }