static void Main() { Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); GSM gsm = new GSM("Galaxy S3", "Samsung"); gsm.AddCall(new Call(DateTime.Now, "5551337", 150)); gsm.AddCall(new Call(DateTime.Now.AddDays(-1), "5551337", 230)); gsm.AddCall(new Call(new DateTime(2013, 2, 19), "5551337", 420)); foreach (var call in gsm.CallHistory) { Console.WriteLine(call); } Console.WriteLine("{0:C}", gsm.CalculateCallsPrice(0.37M)); //get the longest call; Call maxCall = gsm.CallHistory.Where(x => x.Duration == gsm.CallHistory.Max(y => y.Duration)).Single(); //remove the longest call from the call history gsm.RemoveCall(maxCall); //print the total price without the longest call Console.WriteLine("{0:C}", gsm.CalculateCallsPrice(0.37M)); gsm.ClearCallHistory(); foreach (var call in gsm.CallHistory) { Console.WriteLine(call); } }
static void Main() { Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); GSM gsm = new GSM("Galaxy S3", "Samsung"); gsm.AddCall(new Call(DateTime.Now, "5551337", 150)); gsm.AddCall(new Call(DateTime.Now.AddDays(-1), "5551337", 230)); gsm.AddCall(new Call(new DateTime(2013, 2, 19), "5551337", 420)); foreach (var call in gsm.CallHistory) { Console.WriteLine(call); } Console.WriteLine("{0:C}", gsm.CalculateCallsPrice(0.37M)); //get the longest call; Call maxCall = gsm.CallHistory.Where(x => x.Duration == gsm.CallHistory.Max(y => y.Duration)).Single(); //remove the longest call from the call history gsm.RemoveCall(maxCall); //print the total price without the longest call Console.WriteLine("{0:C}", gsm.CalculateCallsPrice(0.37M)); gsm.ClearCallHistory(); foreach (var call in gsm.CallHistory) { Console.WriteLine(call); } }
static void Main(string[] args) { // Creating instance of GSM class and adding some calls GSM justTest = new GSM("Galaxy S", "Samsung", "Not me"); justTest.AddCall(new Call(new DateTime(2013, 2, 25), "0895548299", 100)); justTest.AddCall(new Call(new DateTime(2013, 2, 25), "0895548299", 200)); justTest.AddCall(new Call(new DateTime(2013, 2, 25), "0895548299", 150)); justTest.AddCall(new Call(new DateTime(2013, 2, 25), "0895548299", 170)); // Printing call history foreach (var call in justTest.CallHistory) { Console.WriteLine(call); } // Printing total price of the calls var callsPrice = justTest.CalculateCallsPrice(0.37m); Console.WriteLine("{0}lv", callsPrice); // Removing longest call from call history int longestCall = int.MinValue; int longestCallPosition = 0; for (int i = 0; i < justTest.CallHistory.Count; i++) { if (justTest.CallHistory[i].Duration > longestCall) { longestCall = justTest.CallHistory[i].Duration; longestCallPosition = i; } } justTest.RemoveCall(longestCallPosition); // Printing call history foreach (var call in justTest.CallHistory) { Console.WriteLine(call); } // Clearing call history justTest.ClearCallHistory(); // Printing call history foreach (var call in justTest.CallHistory) { Console.WriteLine(call); } }