public static void TestCallHistory() { GSM phoneOne = new GSM("Galaxy S7 Edge", "Samsung"); Call first = new Call(phoneOne, DateTime.Now, "0864195525", 167); phoneOne.AddCallHistory(first); Call second = new Call(phoneOne, DateTime.Now, "0864195545", 220); phoneOne.AddCallHistory(second); Call thurd = new Call(phoneOne, DateTime.Now, "0846195545", 1000); phoneOne.AddCallHistory(thurd); phoneOne.PrintCallHistory(); phoneOne.CallPrice(); phoneOne.DeleteCallHistory(2); phoneOne.PrintCallHistory(); phoneOne.CallPrice(); phoneOne.ClearCallHistory(); phoneOne.PrintCallHistory(); }
public Call(GSM phone, DateTime date, string dialledPhoneNumber, double duration) { this.Phone = phone; this.Date = date; this.DialledPhoneNumber = dialledPhoneNumber; this.Duration = duration; }
public static void Main() { GSM phoneOne = new GSM("Galaxy S7", "Samsung"); Console.WriteLine(phoneOne.ToString()); GSMTest printPhones = new GSMTest(); printPhones.PrintPhones(); printPhones.DisplayInfoIphone4S(); GSMCallHistoryTest.TestCallHistory(); }
public static void Test() { int longestCall = 0; GSM myGSM = new GSM("One Plus", "X"); myGSM.Owner = "me"; myGSM.AddCall(new Call(new DateTime(2016, 6, 11, 13, 59, 0), "0888888888", 33)); myGSM.AddCall(new Call(new DateTime(2016, 6, 11, 14, 22, 11), "0888888888", 55)); myGSM.AddCall(new Call(new DateTime(2016, 6, 11, 15, 59, 0), "0888888888", 120)); myGSM.AddCall(new Call(new DateTime(2016, 6, 11, 16, 59, 0), "088888888x", 6)); Console.WriteLine("\n-----History of all calls-----"); myGSM.PrintHistory(); Console.WriteLine("\n-----Total price of all calls-----"); int duration = 0; foreach (var call in myGSM.CallHistory) { duration += call.CallDuration; } Console.WriteLine("{0:F2}lv for {1} seconds", myGSM.TotalCallPrice(), duration); foreach (var call in myGSM.CallHistory) { if (longestCall <= call.CallDuration) { longestCall = call.CallDuration; } } foreach (var call in myGSM.CallHistory) { if (longestCall == call.CallDuration) { myGSM.DeleteCall(call); break;//delete only the first if there are multiple longest calls with the same call duration } } Console.WriteLine("\n-----Longest call deleted-----"); myGSM.PrintHistory(); Console.WriteLine("\n-----Phone history deleted-----"); myGSM.ClearHistory(); myGSM.PrintHistory(); }
static void Main(string[] args) { GSM myGSM = new GSM("One Plus", "X"); myGSM.Battery = new Battery("non-removable", 2525, BatteryType.LiPo); myGSM.Owner = "me"; //Console.WriteLine(myGSM.ToString()); //Console.WriteLine(GSM.IPhone4s); GSM iPhone6 = new GSM("Apple", "Iphone6"); GSM samsungS7 = new GSM("Samsung", "S7"); GSM[] allGSMs = new GSM[] { myGSM, GSM.IPhone4s, iPhone6, samsungS7 }; foreach (var gsm in allGSMs) { Console.WriteLine(gsm); } Console.WriteLine("\n-----Call history test-----"); GSMCallHistoryTest.Test(); }