public static void Main() { myPhone.AddCall("11/03/2015", "15:15", "0896000000", 180); myPhone.AddCall("11/03/2015", "15:25", "+359896555555", 60); myPhone.AddCall("11/03/2015", "15:35", "+359896777777", 300); myPhone.AddCall("11/03/2015", "15:45", "+359888888888", 256); Console.WriteLine("Calls Information before:"); foreach (var call in myPhone.CallHistory) { Console.WriteLine("Date: {0}, \nTime: {1}, \nDialed Phone: {2}, \nDuration: {3} seconds\n", call.Date, call.Time, call.PhoneNum, call.Duration); } Console.WriteLine("Total price for all calls: {0}", myPhone.CalculateTotalPrice(0.37)); Console.WriteLine(); Console.WriteLine("Calls Information after:"); List <Call> calls = myPhone.CallHistory; Call maxDurationCall = calls.Max(); calls.Remove(maxDurationCall); foreach (var call in myPhone.CallHistory) { Console.WriteLine("Date: {0}, \nTime: {1}, \nDialed Phone: {2}, \nDuration: {3} seconds\n", call.Date, call.Time, call.PhoneNum, call.Duration); } Console.WriteLine("Total price for all calls: {0}", myPhone.CalculateTotalPrice(0.37)); myPhone.ClearCallHistory(); }
static void Main(string[] args) { GSM[] gsmDevices = new GSM[5]; gsmDevices[0] = new GSM( "N95", "Nokia", 650.60m, "Kukata", new Display(15, 65000), new Battery("Takashi", Battery.BatteryType.NiMH, 0, 0)); gsmDevices[1] = new GSM("Touch Pro 2", "HTC", "VGeorgiev"); gsmDevices[2] = new GSM("Galaxy", "Samsung", "Penka"); gsmDevices[3] = new GSM("Touch Diamond", "HTC", "Stoki"); gsmDevices[4] = new GSM(); for (int i = 0; i < gsmDevices.Length; i++) { Console.WriteLine("Manufacturer: {0} , Model: {1}", gsmDevices[i].Manufacturer, gsmDevices[i].Model); } Console.WriteLine(); Console.WriteLine(GSM.IPhone4S.ToString()); // CAll i var device = new GSM("Touch Pro 2", "HTC", "Vlado"); Call firstCall = new Call(DateTime.Now, 180); Call secondCall = new Call(DateTime.Now, 560); Call thirdCall = new Call(DateTime.Now, 340); device.AddCall(firstCall); device.AddCall(secondCall); device.AddCall(thirdCall); device.DeleteCall(firstCall); Console.WriteLine("Call duration: {0}s, Call price: {1:c}", device.CallHistoryDuration(), device.CallHystoryPrice()); GSM.IPhone4S.Owner = "Pesho"; Console.WriteLine(GSM.IPhone4S.Owner); }
static void Main() { GSM gsm = new GSM(new Display(10, 20, 5, 20), new Battery(BatteryType.NiCd, 43, 34), "Lumia", "Nokia", 100, "Pesho"); var someCalls = new List<Call>(); someCalls.Add(new Call(new DateTime(2015, 3, 13, 13, 24, 45), "0889666060", 100)); someCalls.Add(new Call(new DateTime(2015, 3, 11, 13, 4, 45), "0899606060", 2000)); someCalls.Add(new Call(new DateTime(2015, 3, 12, 13, 2, 4), "0899606060", 130)); someCalls.Add(new Call(new DateTime(2015, 3, 3, 13, 24, 5), "0899606060", 400)); foreach (var call in someCalls) { gsm.AddCall(call); } foreach (var call in gsm.CallHistory) { Console.WriteLine("Date: {0}.{1}.{2} - {3}:{4}:{5}, Phone number: {6}, Duration: {7}s", call.Date.Day, call.Date.Month, call.Date.Year, call.Date.Hour, call.Date.Minute, call.Date.Second, call.DilledPhoneNumber, call.DurationOfCall); } decimal resultTotalPrice = gsm.CalculateTotalPrice(gsm.CallHistory); Console.WriteLine("Total price of all calls: {0:F2}", resultTotalPrice); int longestCall = 0; int indexOfLongestCall = 0; for(int i = 0; i < gsm.CallHistory.Count; i++) { if(gsm.CallHistory[i].DurationOfCall > longestCall) { longestCall = gsm.CallHistory[i].DurationOfCall; indexOfLongestCall = i; } } gsm.DeleteCall(indexOfLongestCall); resultTotalPrice = gsm.CalculateTotalPrice(gsm.CallHistory); Console.WriteLine("Total price without longest call: {0:F2}", resultTotalPrice); gsm.ClearCallHistory(); }