public void TestCalls() { gsm.AddCall("5/1/2008 8:30:52 AM", 2030, 120); gsm.AddCall("6/1/2008 10:50:52 AM", 3040, 360); gsm.AddCall("7/1/2008 11:33:52 AM", 4050, 200); PrintDetails(gsm); Console.WriteLine("Total Call Cost: {0:0.00}$\n", gsm.GetCallsCost(0.37f)); float longestDuration = gsm.CallHistory[0].CallDurationInSeconds; for (int i = 1; i < gsm.CallHistory.Count; i++) { if (gsm.CallHistory[i].CallDurationInSeconds > longestDuration) { longestDuration = gsm.CallHistory[i].CallDurationInSeconds; } } gsm.RemoveCall(longestDuration); Console.WriteLine("Total Call Cost After Longest Call Removal: {0:0.00}$\n", gsm.GetCallsCost(0.37f)); gsm.ClearCallHistory(); Console.WriteLine("Now cleared\n"); PrintDetails(gsm); }
public static void CallHistoryTest() { //Create an instance of the GSM class. GSM myGsm = GSM.IPhone4S; //Add few calls. Call someCall = new Call(DateTime.Now, 120, "+359888888888"); myGsm.AddCall(someCall); myGsm.AddCall(someCall); myGsm.DeleteCall(someCall); myGsm.AddCall(someCall); myGsm.AddCall(new Call(new DateTime(2013, 2, 10, 21, 14, 29), 1000, "0885088508")); myGsm.AddCall(new Call(new DateTime(2013, 1, 20, 11, 11, 11), 1000, "0885088508")); myGsm.AddCall(new Call(DateTime.Now, 119, "+359887121314")); //Display the information about the calls. Console.WriteLine("All calls:"); myGsm.PrintAllCalls(); //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history. PrintCallPrice(myGsm); //Remove the longest call from the historyand calculate the total price again. myGsm.RemoveLongestDurationCall(); Console.WriteLine("\nAfter remove of longest duration call..."); PrintCallPrice(myGsm); //Finally clear the call history and print it. myGsm.ClearCallHistory(); Console.WriteLine("\nAfter clear..."); myGsm.PrintAllCalls(); PrintCallPrice(myGsm); }
public void GsmCallHistoryTest() { GSM gsm = new GSM(); gsm.AddCalls(new Call("12.05.2015", "23:52:31", "+359869256543", 60)); gsm.AddCalls(new Call("03.06.2015", "13:42:32", "+359849213553", 32)); gsm.AddCalls(new Call("24.05.2015", "14:52:33", "+359899228563", 60)); gsm.AddCalls(new Call("15.03.2015", "12:22:34", "+359889237573", 660)); gsm.AddCalls(new Call("26.07.2015", "10:32:35", "+359989246523", 60)); gsm.AddCalls(new Call("17.03.2015", "08:12:36", "+359889255529", 32)); gsm.AddCalls(new Call("08.02.2015", "02:32:37", "+359889264503", 56)); gsm.AddCalls(new Call("29.08.2015", "23:52:37", "+359889273593", 120)); int theLongestCall = 0; int index = 0; if (gsm.HistoryCall.Count != 0) { for (int i = 0; i < gsm.HistoryCall.Count; i++) { Console.WriteLine(gsm.HistoryCall[i]); if (gsm.HistoryCall[i].Duration > theLongestCall) { theLongestCall = gsm.HistoryCall[i].Duration; index = i; } Console.WriteLine(new string('-', 70)); } } else { Console.WriteLine("The call history is empty"); } Console.WriteLine("Total price of the calls in the call history is: {0}", gsm.TotalPriceOfTheCallHistory(0.37M)); gsm.DeleteCalls(index); Console.WriteLine(new string('-', 70)); Console.WriteLine("After remove the longest call:"); Console.WriteLine("Total price of the calls in the call history is: {0}", gsm.TotalPriceOfTheCallHistory(0.37M)); Console.WriteLine(new string('-', 70)); gsm.ClearCallHistory(); if (gsm.HistoryCall.Count != 0) { foreach (var item in gsm.HistoryCall) { Console.WriteLine(item); } } else { Console.WriteLine("The call history is empty"); } }
public static void Test() { //Create Instance of GSM GSM myMobile = new GSM("One", "HTC", 1240, "Pratchett, Terry", new Display(720, 1280, 4.5, 64000000), new Battery("2070 mAh", 300, 150, Battery.BatteryTypes.LiIon) ); //Add some calls to CallHistory Call callOne = new Call(DateTime.Now, "+898 888 888", 1204); Call callTwo = new Call(DateTime.Now.AddDays(1), "+888 888 898", 1024); Call callThree = new Call(DateTime.Now.AddDays(1), "+888 888 898", 200); Call callFour = new Call(DateTime.Now.AddHours(1), "+888 898 898", 2020); myMobile.CallHistory.Add(callOne); myMobile.CallHistory.Add(callTwo); myMobile.CallHistory.Add(callThree); myMobile.CallHistory.Add(callFour); //Display the information about the calls Console.WriteLine("All calls information\n"); foreach (Call item in myMobile.CallHistory) { Console.WriteLine(item); } //Assuming that the price per minute is 0.37 calculate and print //the total price of the calls in the history. Console.WriteLine("Calculate price example: "); var pricePerMinute = 0.37m; Console.WriteLine("Price of all calls {0:c}", myMobile.CallculatePrice(pricePerMinute)); //Remove the longest call from the history and calculate the total price again. //find the longest call Call longestCall = FindLongestCall(myMobile); //remove the longest call myMobile.RemoveCall(longestCall); //calculate the price again and print it Console.WriteLine("Price after removing longest call: {0:c}", myMobile.CallculatePrice(pricePerMinute)); //Finally clear the call history and print it. Console.WriteLine("\nBefore clear call history stores {0} items", myMobile.CallHistory.Count); myMobile.ClearCallHistory(); Console.WriteLine("Now call history stores {0} items", myMobile.CallHistory.Count); }
public void Test() { gsm.AddCall(new Call(new DateTime(2016, 05, 15, 18, 30, 22), "0885 654 213", 100)); gsm.AddCall(new Call(new DateTime(2015, 11, 22, 13, 45, 23), "0888 352 351", 100)); gsm.AddCall(new Call(new DateTime(2016, 09, 19, 15, 30, 44), "0887 424 212", 100)); Console.WriteLine(gsm.CallHistoryInfo()); Console.WriteLine("Total price: {0:F2} BGN", gsm.CallPrice(0.37m)); gsm.RemoveLongestCall(); Console.WriteLine("Now the total price is {0:F2} BGN", gsm.CallPrice(0.37m)); gsm.ClearCallHistory(); Console.WriteLine(gsm.CallHistoryInfo()); }
public static void Main() { try { Display display = new Display(4, 16000000); Battery battery = new Battery(620, 8, Battery.BatteryModel.NiMH); GSM phone = new GSM("One", "HTC", 850, "Person", battery, display); GSMTest test = new GSMTest(); Console.WriteLine("============="); test.GSMTesting(); Console.WriteLine("============="); DateTime time = new DateTime(); time = DateTime.Now; Calls[] call = new Calls[5]; //making some phone calls for (int i = 0; i < 5; i++) { time = time.AddDays(i); string phoneNumber = "0888999999"; int duration = i + 100; call[i] = new Calls(time, phoneNumber, duration); phone.AddCall(call[i]); } Console.WriteLine(); decimal pricePerMinute = 0.37m; //display call information phone.CallHistory(); Console.WriteLine("============="); phone.TotalPriceOfCalls(pricePerMinute); Console.WriteLine("============="); phone.FindLongestCall(); phone.TotalPriceOfCalls(pricePerMinute); Console.WriteLine("============="); phone.ClearCallHistory(); phone.CallHistory(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void Main(string[] args) { //zad.7 GSMTest.PrintInfo(); //Create an instance of the GSM class. GSM myPhone = new GSM("N95", "Nokia"); //Add few calls. Call call = new Call(DateTime.Now, "0883333333", 60); Call nextCall = new Call(new DateTime(2013,02,10,20,34,20), "+3592376541212", 120); myPhone.AddCall(call); myPhone.AddCall(nextCall); //Display the information about the calls. foreach (var c in myPhone.CallHistory) { Console.WriteLine(c); } //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history. Console.Write("The total price of the calls is: "); myPhone.PriceOfCalls(0.37m); //Remove the longest call from the history and calculate the total price again. Call longest = new Call(); longest.Duration = 0; for (int i = 0; i < myPhone.CallHistory.Count; i++) { if (myPhone.CallHistory[i].Duration > longest.Duration) { longest = myPhone.CallHistory[i]; } } myPhone.RemoveCall(longest); Console.Write("The new price after removing longest call is: "); myPhone.PriceOfCalls(0.37m); //Finally clear the call history and print it. myPhone.ClearCallHistory(); foreach (var c in myPhone.CallHistory) { Console.WriteLine(c); } }
public static void TestHistory() { var nokia = new GSM("Nokia", "Lumia920", 500.50, "Gosho", new Battery("Mistucura-1224fe", 40, 5, BatteryTypes.NiMh), new Display(3.5, ColorDepth._16Bit)); nokia.AddCallHistory(0888124122, 210); nokia.AddCallHistory(0888124122, 40); nokia.AddCallHistory(0888124122, 80); nokia.AddCallHistory(0919125121, 600); nokia.AddCallHistory(0919125121, 10); nokia.ShowCalls(); Console.WriteLine("The price of all calls is - {0}", nokia.CalculatePriceForTalk(0.37m)); nokia.RemuveLongestCall(); Console.WriteLine("The price of all calls is - {0}", nokia.CalculatePriceForTalk(0.37m)); nokia.ClearCallHistory(); nokia.ShowCalls(); }
public static void CallsHistoryTest() { foreach (Call call in calls) { test.AddCall(call); } Console.WriteLine("\n\nPresenting information about three calls:"); Console.WriteLine(new string('=', 41)); foreach (Call call in test.CallHistory) { Console.WriteLine(call); } Console.WriteLine("\nTotal price of the calls: {0}", test.CallsTotalPrice(0.37m)); Call longestCall = test.CallHistory[0]; for (int i = 1; i < test.CallHistory.Count; i++) { if (test.CallHistory[i].Duration > longestCall.Duration) { longestCall = test.CallHistory[i]; } } test.CallHistory.Remove(longestCall); Console.WriteLine("\nRemoving the longest call:"); Console.WriteLine(longestCall); Console.WriteLine("\nTotal price of the calls (after the removing): {0}", test.CallsTotalPrice(0.37m)); test.ClearCallHistory(); Console.WriteLine("\nClearing the call history..."); Console.WriteLine("\nTotal price of the calls: {0}", test.CallsTotalPrice(0.37m)); Console.WriteLine(new string('=', 34)); }
private static void GSMCallHistoryTest() { GSM testGsm = new GSM("Privileg", "MyFriend"); testGsm.AddCall(DateTime.Now, "+359895258796", 48); testGsm.AddCall(DateTime.Now, "+359872456789", 899); testGsm.AddCall(DateTime.Now, "+359973679023", 68); testGsm.AddCall(DateTime.Now, "+359111222333", 25); testGsm.AddCall(DateTime.Now, "+359444555666", 348); testGsm.ShowCallHistory(); Console.WriteLine("Total call price: " + testGsm.TotalCallPrice()); testGsm.DeleteCall(1); Console.WriteLine("Removed the longest call!"); Console.WriteLine("Total call price: " + testGsm.TotalCallPrice()); testGsm.ClearCallHistory(); Console.WriteLine("Cleared call history!"); testGsm.ShowCallHistory(); }
private static void GSMCallHistoryTest() { GSM testGsm = new GSM("Nokia", "TelerikCorp"); testGsm.AddCall("0888888881", 20); testGsm.AddCall("0888888882", 60); testGsm.AddCall("0888888883", 10); testGsm.AddCall("0888888884", 30); testGsm.AddCall("+359888888885", 250); testGsm.ShowCallHistory(); Console.WriteLine("Total call price: " + testGsm.TotalCallPrice()); testGsm.DeleteCall(5); Console.WriteLine("Removed Longest call!"); Console.WriteLine("Total call price: " + testGsm.TotalCallPrice()); testGsm.ClearCallHistory(); Console.WriteLine("Cleared call history!"); testGsm.ShowCallHistory(); }
public static void TestGSMCallHistory() { GSM gsm = new GSM("10", "Samsung"); gsm.PerformCall("0864743331", 110); gsm.PerformCall("0891362423", 65); gsm.PerformCall("0870303991", 304); Console.WriteLine(gsm.PrintCallHistory()); Console.WriteLine(gsm.TotalCallsPrice(0.37)); Call call = gsm.CallHistory[0]; foreach (var historyCall in gsm.CallHistory) { if (call.Duration < historyCall.Duration) { call = historyCall; } } gsm.CallHistory.Remove(call); Console.WriteLine(gsm.TotalCallsPrice(0.37)); gsm.ClearCallHistory(); Console.WriteLine(gsm.PrintCallHistory()); }