static void Main() { GSM MyGSM = new GSM("Galaxy S4", "Samsung",750.00m,"Slavi"); // create an instance of the GSM class to test the call history functionality MyGSM.AddCall(new Call(new DateTime(2013, 09, 24, 10, 33, 00), "0887551432", 133)); MyGSM.AddCall(new Call(new DateTime(2013, 09, 24, 11, 54, 10), "0886113432", 63)); MyGSM.AddCall(new Call(new DateTime(2013, 09, 24, 23, 11, 23), "0886113432", 234)); MyGSM.AddCall(new Call(new DateTime(2013, 09, 25, 07, 30, 03), "+359887551432", 73)); MyGSM.AddCall(new Call(new DateTime(2013, 09, 25, 10, 04, 27), "+359897143223", 105)); MyGSM.AddCall(new Call(new DateTime(2013, 09, 26, 15, 10, 55), "0878751030", 15)); //add few calls and prints call history MyGSM.PrintCallHistory(); Console.WriteLine(); Console.WriteLine("The total price for the calls is: {0} BGN", MyGSM.CalcTotalPriceCallHistory(0.37m)); //finds the longest call index int maxDuration = -1; int maxIndex = -1; for (int i = 0; i < MyGSM.CallHistory.Count; i++) { if (MyGSM.CallHistory[i].Duration > maxDuration) { maxDuration = (int)MyGSM.CallHistory[i].Duration; maxIndex = i; } } MyGSM.RemoveCall(maxIndex); //removes the call with the maximum duration and prints MyGSM.PrintCallHistory(); Console.WriteLine("The total price for the calls is: {0} BGN", MyGSM.CalcTotalPriceCallHistory(0.37m)); Console.WriteLine(); MyGSM.DeleteHistory(); //clears all calls from the history and prints again MyGSM.PrintCallHistory(); }
public static void TestGSMCallHistory() { GSM gsm = new GSM("10", "Samsung"); gsm.PerformCall("0864743331", 110); gsm.PerformCall("0891362423", 65); gsm.PerformCall("0870303991", 304); Console.WriteLine(gsm.PrintCallHistory()); Console.WriteLine(gsm.TotalCallsPrice(0.37)); Call call = gsm.CallHistory[0]; foreach (var historyCall in gsm.CallHistory) { if (call.Duration < historyCall.Duration) { call = historyCall; } } gsm.CallHistory.Remove(call); Console.WriteLine(gsm.TotalCallsPrice(0.37)); gsm.ClearCallHistory(); Console.WriteLine(gsm.PrintCallHistory()); }