public static void PrintCallHistory(GSM gsm) { Console.WriteLine("-----------------------------"); foreach (var item in gsm.CallHistory) { Console.WriteLine("Time: {0}", item.DateAndTime); Console.WriteLine("Number: {0}", item.DialedNumber); Console.WriteLine("Duration: {0} sec", item.Duration); Console.WriteLine("-----------------------------"); } }
public static void TestCalls() { GSM mySiemens = new GSM("M35", "Siemens"); mySiemens.AddCall(new Call(DateTime.Now, "+359 88 762 96 96", 72)); mySiemens.AddCall(new Call(DateTime.Today, "+359 99 923 33 33", 245)); mySiemens.AddCall(new Call(DateTime.UtcNow, "+359 87 244 67 88", 456)); PrintCallHistory(mySiemens); Console.WriteLine("Total call price: {0:0.00}", mySiemens.TotalCallPrice(0.37M)); mySiemens.DeleteCall(LongestCallIndex(mySiemens) + 1); Console.WriteLine("Modified total call price: {0:0.00}", mySiemens.TotalCallPrice(0.37M)); mySiemens.ClearCallHistory(); PrintCallHistory(mySiemens); }
public static int LongestCallIndex(GSM gsm) { int maxDuration = 0; int longestCallIndex = 0; for (int i = 0; i < gsm.CallHistory.Count; i++) { if (gsm.CallHistory[i].Duration > maxDuration) { maxDuration = gsm.CallHistory[i].Duration; longestCallIndex = i; } } return longestCallIndex; }
public static int LongestCallIndex(GSM gsm) { int maxDuration = 0; int longestCallIndex = 0; for (int i = 0; i < gsm.CallHistory.Count; i++) { if (gsm.CallHistory[i].Duration > maxDuration) { maxDuration = gsm.CallHistory[i].Duration; longestCallIndex = i; } } return(longestCallIndex); }
public static void Test() { GSM[] gsmArray = new GSM[3]; gsmArray[0] = new GSM("Lumia 926", "Nokia"); gsmArray[1] = new GSM("Galaxy S4", "Samsung", 299.99, "John Smith", new Battery("2600 mAh"), new Display()); gsmArray[2] = new GSM("Windows Phone 8", "HTC"); gsmArray[0].Owner = "Ivan Petrov"; gsmArray[2].Owner = "Jack Daniels"; gsmArray[2].Price = 399.99; Battery htcBattery = new Battery("1800 mAh", 370, 17, BatteryType.LiIon); Display htcDisplay = new Display(720, 16000000); gsmArray[2].GSMBattery = htcBattery; gsmArray[2].GSMDisplay = htcDisplay; foreach (var item in gsmArray) { Console.WriteLine(item); } Console.WriteLine(GSM.IPhone4S.ToString()); Console.WriteLine("-----------------------------"); }