public void CallHistoryTest() { GSM myPhone = new GSM("Lumia", "Nokia"); //public Call(string date, string time, string dialed, long duration) List <Call> someCalls = new List <Call> { new Call("02.02.2015", "15:45", "0896232333", 56), new Call("03.18.2015", "11:45", "0852454555", 13), new Call("01.02.2015", "00:05", "0899656598", 118), new Call("03.15.2015", "18:32", "0896232333", 65) }; foreach (Call a in someCalls) { myPhone.AddCall(a); } myPhone.DisplayCalls(); double price = 0.37; Console.WriteLine("With price of 0.37 per minute, the total cost of the calls:" + myPhone.CalcPrice(price / 60)); Console.WriteLine("Removing the longest call ..."); myPhone.DeleteCall(someCalls[2]); Console.WriteLine("With price of 0.37 per minute, the total cost of the calls:" + myPhone.CalcPrice(price / 60)); myPhone.ClearHistory(); Console.WriteLine("History Cleared"); Console.WriteLine("Current History:"); myPhone.DisplayCalls(); }
private static void Main() { // Inserting data: GSM myPhone = new GSM("Nokia", "Nokia OOD"); myPhone.Price = 500; myPhone.Owner = "Ivancho"; myPhone.battery = new Battery(BatteryType.NiMH); myPhone.battery.HourIdle = 12; myPhone.battery.HoursTalk = 520; myPhone.display = new Display(12); myPhone.display.NumberOfColors = 326; // Transfering data and printing Console.WriteLine(myPhone.PrintMobileInfo(myPhone.battery, myPhone.display)); // Iphone4S data: string theIPhoneInfo = GSM.IPhone4S; Console.WriteLine(theIPhoneInfo); // and ETC GSM phone = new GSM("Alcatel", "Alacatelov"); GSMTest.CreateAFewGSMs(5); // Adding calls myPhone.resentCall = new Call("0898123231"); Console.WriteLine(myPhone.resentCall.LastNumber); myPhone.CallHistory.Add(myPhone.resentCall); // Adding a second call myPhone.resentCall = new Call("08788765426"); // Adding the call to the list myPhone.CallHistory.Add(myPhone.resentCall); foreach (Call talk in myPhone.CallHistory) { Console.WriteLine(talk.LastNumber); } // From here on, the adding to the callHistory is automatic myPhone.AddAndRemove("add", myPhone); myPhone.AddAndRemove("remove", myPhone); double totalPrice = myPhone.TotalPriceOfCalls(myPhone); // Not working because I don't have thread.sleep or something to make timespan Console.WriteLine("Total price: {0}", totalPrice); // Clearing the history myPhone.ClearHistory(); GSMCallHistoryTest.GSMTest(); }
public void CallHistoryTest() { GSM myPhone = new GSM("Lumia", "Nokia"); //public Call(string date, string time, string dialed, long duration) List<Call> someCalls =new List<Call> { new Call("02.02.2015", "15:45", "0896232333", 56), new Call("03.18.2015", "11:45", "0852454555", 13), new Call("01.02.2015", "00:05", "0899656598", 118), new Call("03.15.2015", "18:32", "0896232333", 65)}; foreach (Call a in someCalls) { myPhone.AddCall(a); } myPhone.DisplayCalls(); double price = 0.37; Console.WriteLine("With price of 0.37 per minute, the total cost of the calls:" + myPhone.CalcPrice(price/60)); Console.WriteLine("Removing the longest call ..."); myPhone.DeleteCall(someCalls[2]); Console.WriteLine("With price of 0.37 per minute, the total cost of the calls:" + myPhone.CalcPrice(price / 60)); myPhone.ClearHistory(); Console.WriteLine("History Cleared"); Console.WriteLine("Current History:"); myPhone.DisplayCalls(); }
public static void Test() { var phone = new GSM("MyPhone", "Apple"); phone.AddCall(new Call(DateTime.Now, "Pesho", 45)); phone.AddCall(new Call(DateTime.Now, "Ivan", 18)); phone.AddCall(new Call(DateTime.Now, "Gosho", 80)); // phone.PrintCalls(); Console.WriteLine(phone.CallsToString()); Console.WriteLine("Total Price: {0:f2}", phone.CallsPrice(0.37)); var longestCall = phone .CheckCalls() .OrderByDescending(x => x.Duration) .FirstOrDefault(); if (phone.RemoveCall(longestCall)) { Console.WriteLine("Longest call was removed"); } else { // if cant remove longest call then probably list is empty Console.WriteLine("Are you sure there are calls in phone call history?"); } Console.WriteLine("Total Price: {0:f2}", phone.CallsPrice(0.37)); phone.ClearHistory(); //phone.PrintCalls(); Console.WriteLine(phone.CallsToString()); }
public static void CallHistoryTest() { // Create an instance of the GSM class. GSM myFirstIPhone = new GSM( "IPhone5", "Apple", 55.99, "Gosho Bacov", new Display(9, 500000000), new Battery(BatteryType.LithiumSulfur, "Li-lon", 10, 4.5), new Call(DateTime.Now, "0899 513 321", 60)); // Add few calls. myFirstIPhone.AddCall(new Call(DateTime.UtcNow, "0888 888 888", 162)); myFirstIPhone.AddCall(new Call(DateTime.Today, "0999 235 123", 42)); myFirstIPhone.AddCall(new Call(DateTime.Now, "0999 999 999", 70)); // Display the information about the calls. var historyCalls = myFirstIPhone.CallHistory; foreach (var call in historyCalls) { Console.WriteLine(call.ToString()); Console.WriteLine(); } // Assuming that the price per minute is 0.37 calculate // and print the total price of the calls in the history. double price; price = myFirstIPhone.CallPrice(myFirstIPhone.CallHistory); Console.WriteLine($"{price:F2}"); Console.WriteLine(); // Remove the longest call from the history and calculate the total price again. var historyCallsList = myFirstIPhone.CallHistory; int longestCall = historyCallsList[0].DurationInSeconds; Call callForRemuve = myFirstIPhone.CallHistory[0]; foreach (var call in historyCallsList) { if (longestCall < call.DurationInSeconds) { callForRemuve = call; } } myFirstIPhone.DelCall(callForRemuve); // print again historyCalls = myFirstIPhone.CallHistory; foreach (var call in historyCalls) { Console.WriteLine(call.ToString()); Console.WriteLine(); } double newPrice; newPrice = myFirstIPhone.CallPrice(myFirstIPhone.CallHistory); Console.WriteLine($"{newPrice:F2}"); Console.WriteLine(); // Finally clear the call history and print it. myFirstIPhone.ClearHistory(); if (myFirstIPhone.CallHistory.Count == 0) { Console.WriteLine("Call history is EMPTY !!!"); } else { historyCalls = myFirstIPhone.CallHistory; foreach (var call in historyCalls) { Console.WriteLine(call.ToString()); Console.WriteLine(); } } }