public void TestCallHistory() { var a = new Call(new DateTime(2018, 07, 21, 10, 54, 6), new DateTime(2018, 07, 21, 10, 54, 6), "0888 265 897", 55); lastGSM.AddCall(a); var b = new Call(new DateTime(2018, 07, 21, 12, 35, 9), new DateTime(2018, 07, 21, 12, 35, 9), "0887 355 887", 60); lastGSM.AddCall(b); var c = new Call(new DateTime(2018, 07, 21, 13, 38, 10), new DateTime(2018, 07, 21, 13, 38, 10), "0879 548 486", 30); lastGSM.AddCall(c); Console.WriteLine(lastGSM.CallHistoryInfo()); Console.WriteLine("Total Price: {0:C2}", lastGSM.CalculatePrice(pricePerMin)); var longestCall = lastGSM.CallHistory.OrderByDescending(x => x.Duration).First(); lastGSM.RemoveCall(longestCall); Console.WriteLine("Price after deleting the longest call: {0:C2}", lastGSM.CalculatePrice(pricePerMin)); lastGSM.ClearHistory(); Console.WriteLine(lastGSM.CallHistoryInfo()); }
public static void Test() { Console.WriteLine(); Console.WriteLine("GSM Call History Test:"); GSM myGSM = new GSM("C2-01", "Nokia"); DateTime date = new DateTime(); TimeSpan time = new TimeSpan(); date = DateTime.Now.Date; time = DateTime.Now.TimeOfDay; myGSM.AddCall(date, time, 98325, 33); myGSM.AddCall(date.AddDays(2), time, 111111, 67); myGSM.AddCall(date.AddDays(7), time, 324624, 50); int maxIndex = 0; for (int index = 0; index < myGSM.CallHistory.Count; index++) { if (myGSM.CallHistory[maxIndex].Duration < myGSM.CallHistory[index].Duration) { maxIndex = index; } Console.WriteLine(myGSM.CallHistory[index].ToString()); } Console.WriteLine(); Console.Write("The total price for all calls is: {0}$", myGSM.CalculatePrice(0.37m)); Console.WriteLine(); Console.WriteLine("The longest call duration is {0}",myGSM.CallHistory[maxIndex].ToString()); myGSM.DeleteCall(maxIndex); Console.WriteLine("The new price without the longest call is: {0}$",myGSM.CalculatePrice(0.37m)); myGSM.ClearCallHistory(); }
static void Main() { GSM nokia = new GSM("E-65", "Nokia"); nokia.AddCall("0889186005", 237); nokia.AddCall("0889182205", 114); nokia.AddCall("0889346005", 87); nokia.AddCall("0889346108", 111); nokia.DisplayCallInformation(); Console.WriteLine("Current bill for this number {0} Leva.\n", nokia.GetCallsPrice(0.37m)); nokia.RemoveCall(); nokia.DisplayCallInformation(); nokia.ClearCallHistory(); nokia.DisplayCallInformation(); }
static void Main() { GSM nokia = new GSM("E-65", "Nokia"); nokia.AddCall("0889186005", 237); nokia.AddCall("0889182205", 114); nokia.AddCall("0889346005", 87); nokia.AddCall("0889346108", 111); nokia.DisplayCallInformation(); Console.WriteLine("Current bill for this number {0} Leva.\n", nokia.GetCallsPrice(0.37m)); nokia.RemoveCall(); nokia.DisplayCallInformation(); nokia.ClearCallHistory(); nokia.DisplayCallInformation(); }