static void Main() { //GSM[] arr = new GSM[3]; //arr[0] = new GSM("Google Nexus 3", "Samsung", 400, "-", new Battery("Removable", BatteryType.LiIon, 270, 8), new Display(4.65f, 16000000)); //arr[1] = new GSM("Galaxy S5", "Samsung", 800, "-", new Battery("Removable", BatteryType.LiIon, 390, 21), new Display(5.1f, 16000000)); //arr[2] = new GSM("Ascend P7", "Huawei", 650, "-", new Battery("Non-removable", BatteryType.LiPol, 422, 14), new Display(5f, 16000000)); //for (int i = 0; i < arr.Length; i++) //{ // Console.WriteLine(arr[i]); // Console.WriteLine(); //} Console.WriteLine(GSM.IPhone4S); Console.WriteLine(); var myPhone = new GSM("Google Nexus 3", "Samsung", 400, "-", new Battery("Removable", BatteryType.LiIon, 270, 8), new Display(4.65f, 16000000)); myPhone.AddCall(new Call(new DateTime(2015, 3, 5, 10, 15, 7), "+359880123456", 10)); myPhone.AddCall(new Call(new DateTime(2015, 3, 6, 8, 13, 7), "+359888888888", 65)); myPhone.AddCall(new Call(new DateTime(2015, 3, 7, 13, 17, 7), "+359880123456", 100)); myPhone.AddCall(new Call(new DateTime(2015, 3, 8, 22, 37, 7), "0880123456", 50)); PrintTotal(myPhone); myPhone.DeleteCall(2); // longest call is with index 2 PrintTotal(myPhone); myPhone.ClearCalls(); PrintTotal(myPhone); }
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 List<Calls> RemoveLongestCall(GSM phone, List<Calls> CallHistory) { Calls longestCall = CallHistory[0]; foreach (Calls call in CallHistory) { if (call.Duration > longestCall.Duration) { longestCall = call; } } phone.DeleteCall(longestCall); return CallHistory; }
public static List <Calls> RemoveLongestCall(GSM phone, List <Calls> CallHistory) { Calls longestCall = CallHistory[0]; foreach (Calls call in CallHistory) { if (call.Duration > longestCall.Duration) { longestCall = call; } } phone.DeleteCall(longestCall); return(CallHistory); }
static void Main(string[] args) { GSM gsm = new GSM("testModel", "testManufacturer"); gsm.AddCall(new Call("11.02.2013", "18:32", "00000000", 432)); gsm.AddCall(new Call("11.02.2013", "19:02", "00000001", 23)); gsm.AddCall(new Call("12.02.2013", "11:28", "00000010", 5243)); foreach (Call call in gsm.CallHistory) { Console.WriteLine("Call date: " + call.Date); Console.WriteLine("Call time: " + call.Time); Console.WriteLine("Call phone number: " + call.PhoneNumber); Console.WriteLine("Call duration: " + call.Duration); Console.Write("\n"); } Console.WriteLine("Total price: " + gsm.TotalPrice(0.37m)); gsm.DeleteCall(2); Console.WriteLine("Total price without the longest call: " + gsm.TotalPrice(0.37m)); Console.Write("\n"); foreach (Call call in gsm.CallHistory) { Console.WriteLine("Call date: " + call.Date); Console.WriteLine("Call time: " + call.Time); Console.WriteLine("Call phone number: " + call.PhoneNumber); Console.WriteLine("Call duration: " + call.Duration); Console.Write("\n"); } gsm.ClearCallHistory(); foreach (Call call in gsm.CallHistory) { Console.WriteLine("Call date: " + call.Date); Console.WriteLine("Call time: " + call.Time); Console.WriteLine("Call phone number: " + call.PhoneNumber); Console.WriteLine("Call duration: " + call.Duration); Console.Write("\n"); } }
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(); }
static void CallHistoryTest() { decimal pricePerMinute = 0.37m; Console.WriteLine("Let we test th call history! Ready? ...................\n"); GSM GFlex = new GSM("G-Flex", "LG", (decimal)399.99, "Pavkata", new Battery("G5", 90, 8, BatteryType.LithiumPolymer), new Display((decimal)5.2, 16000000)); GFlex.AddCall(new Calls("01/01/2001", "00:01", "0883654675", 567)); GFlex.AddCall(new Calls("20/07/2013", "22:40", "0894223760", 120)); GFlex.AddCall(new Calls("29/02/2016", "05:10", "0899132465", 221)); GFlex.AddCall(new Calls("16/06/2016", "11:59", "0895386583", 21)); GFlex.AddCall(new Calls("31/06/2016", "06:09", "0877975201", 243)); for (int i = 0; i < GFlex.History.Count; i++) { Console.WriteLine(GFlex.History[i]); } Console.WriteLine("Calls Price: {0:F2}", GFlex.totalPrice(pricePerMinute)); Calls longest = GFlex.History[0]; foreach (var call in GFlex.History) { if (call.CallDuration > longest.CallDuration) { longest = call; } } GFlex.DeleteCall(longest); Console.WriteLine("Calls Price without longest: {0:F2}", GFlex.totalPrice(pricePerMinute)); GFlex.ClearCallHistory(); Console.WriteLine("Call history cleared!"); }
public static void CallHistoryTest() { Console.WriteLine("*************Call History Test*************"); //Create an instance of the GSM class. GSM samsung = new GSM("S5", "Samsung", 1000, "Ivancho", new Battery("G2", 50, 5, BatteryType.LiIon), new Display(5, 500000)); //Add few calls. samsung.AddCall(new Call("30/05/2016", "14:06", "0884089756", 104)); samsung.AddCall(new Call("23/01/2015", "12:42", "0883208975", 311)); samsung.AddCall(new Call("31/04/2016", "11:12", "0884589752", 151)); //Display the information about the calls. for (int i = 0; i < samsung.CallHistory.Count; i++) { Console.WriteLine(samsung.CallHistory[i]); } //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history. Console.WriteLine("Calls Price: {0:f2}", samsung.GetTotalCallPrice(0.37m)); //Remove the longest call from the history and calculate the total price again. Call longestCall = samsung.CallHistory[0]; foreach (var call in samsung.CallHistory) { if (call.Duration > longestCall.Duration) { longestCall = call; } } samsung.DeleteCall(longestCall); Console.WriteLine("Calls Price without longest: {0:f2}", samsung.GetTotalCallPrice(0.37m)); //Finally clear the call history and print it. samsung.ClearCallHistory(); Console.WriteLine("Call history cleared!"); }
public void CallHistoryTest() { GSM peshoGSM = new GSM("Nokia", "Nokia"); Call firstCall = new Call(DateTime.Now, "0888080808", 3000); Call secondCall = new Call(DateTime.Now,"0888080808", 3500); Call thirdCall = new Call(DateTime.Now, "0888080808", 2000); peshoGSM.AddCall(firstCall); peshoGSM.AddCall(secondCall); peshoGSM.AddCall(thirdCall); Console.WriteLine(peshoGSM.CallHistoryInfo()); decimal price = 0.37M; Console.WriteLine("Total price: {0:F2}",peshoGSM.CalculateTotalPriceOfCalls(price)); int longest=0; Call longestCall = new Call(DateTime.Now,"0888888888",0); for (int i = 0; i < peshoGSM.CallHistory.Count; i++) { if (peshoGSM.CallHistory[i].Duration > longest) { longest = peshoGSM.CallHistory[i].Duration; longestCall = peshoGSM.CallHistory[i]; } } peshoGSM.DeleteCall(longestCall); Console.WriteLine("Total price after longest call has been removed: {0:F2}", peshoGSM.CalculateTotalPriceOfCalls(price)); peshoGSM.ClearCalls(); peshoGSM.CallHistoryInfo(); }