public AddCall ( DateTime startDateTime, DateTime endDateTime, string dialedNumber ) : void | ||
startDateTime | DateTime | |
endDateTime | DateTime | |
dialedNumber | string | |
Результат | void |
public GSM AddTestCalls(GSM phone) { phone.AddCall(DateTime.Now, 3, "087612312"); phone.AddCall(DateTime.Now, 2, "089810345"); phone.AddCall(DateTime.Now, 5, "088832323"); return phone; }
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); } }
public GSM AddTestCalls(GSM phone) { phone.AddCall(DateTime.Now, 3, "087612312"); phone.AddCall(DateTime.Now, 2, "089810345"); phone.AddCall(DateTime.Now, 5, "088832323"); return(phone); }
private static void CallsInfo() { // 12. Test the call history functionality of the GSM class. GSM gsm = new GSM("Optimus", "LG"); // 12.1 Create an instance of the GSM class. // 12.2 Add few calls. gsm.AddCall(DateTime.Now, 0871111111, 60); gsm.AddCall(DateTime.Now, 0882222222, 200); gsm.AddCall(DateTime.Now, 0893333333, 1234); // 12.3 Display the information about the calls. gsm.PrintHistory(); /* 12.4 Assuming that the price per minute is 0.37 Calculate and print the total price of the calls in the history. */ Console.WriteLine("The cost of calls is: {0:C2}", gsm.CallPrice(0.37f)); // 12.5 Remove the longest call from the history and calculate the total price again. gsm.DeleteCall(1234); Console.WriteLine("The cost of calls without the longest one is: {0:C2}", gsm.CallPrice(0.37f)); // 12.6 Finally clear the call history and print it. gsm.ClearHistory(); gsm.PrintHistory(); Console.WriteLine("History is cleared!" + Environment.NewLine); Main(); }
public void PhoneCalls() { GSM myPhone = new GSM("Galaxy Note II", "Samsung"); myPhone.AddCall(new DateTime(2013, 02, 1), new DateTime(), "0891111111", 1); myPhone.AddCall(new DateTime(2013, 02, 2), new DateTime(), "0892222222", 2); myPhone.AddCall(new DateTime(2013, 02, 3), new DateTime(), "0893333333", 3); // Display Call History foreach (var call in myPhone.CallHistory) { Console.WriteLine(call); Console.WriteLine(); } // Dispay the bill Console.WriteLine("Bill: {0}lv.", myPhone.CalcBill(0.37m)); // Remove the longest call from the history and calculate the total price again. myPhone.CallHistory.Remove(myPhone.CallHistory[2]); Console.WriteLine("Bill without longest call: {0}lv.", myPhone.CalcBill(0.37m)); //Clear CallHistory Console.WriteLine("Cleaned History"); myPhone.ClearAllHistory(); }
static void Main(string[] args) { var calls = new Call[] { new Call(DateTime.Now, TimeSpan.FromSeconds(52), "3598873629", 15), new Call(DateTime.Now, TimeSpan.FromSeconds(23), "3598546846", 25), new Call(DateTime.Now, TimeSpan.FromSeconds(45), "3597994516", 35) }; var gsm = new GSM("6", "Nexus"); gsm.AddCall(calls[0]); gsm.AddCall(calls[1]); gsm.AddCall(calls[2]); foreach (var call in gsm.CallHistory) { Console.WriteLine(call); } Console.WriteLine(gsm.CalculateTotalPrice(0.37m)); gsm.DeleteCall(calls[2]); Console.WriteLine(gsm.CalculateTotalPrice(0.37m)); gsm.ClearCall(); Console.WriteLine(gsm.CalculateTotalPrice(0.37m)); }
public static void Main() { // Again, you can find the classes for the whole homework in the GSMModules.cs and Calls.cs files, in the Solution's root directory and in the Solution Items in Visual Studio GSM phone = new GSM("Nokia", "Tuhla", "3310"); Call call1 = new Call(new DateTime(2015, 3, 14, 12, 12, 10), "048 155 22", 69.69); Call call2 = new Call(new DateTime(2015, 3, 14, 13, 20, 0), "112", 2.5); Call call3 = new Call(new DateTime(2015, 3, 14, 14, 10, 22), "911", 12.4); phone.AddCall(call1); phone.AddCall(call2); phone.AddCall(call3); Console.WriteLine("Call history:"); Console.WriteLine(phone.CallHistoryToString()); Console.WriteLine("Total Price: " + phone.CallsPrice(0.37).ToString("F2")); phone.RemoveCall(call1); Console.WriteLine("Total Price without longest call: " + phone.CallsPrice(0.37).ToString("F2")); phone.ClearCallHistory(); Console.WriteLine("After clearing call history:"); Console.WriteLine(phone.CallHistoryToString()); }
static void Main() { GSM gsm = new GSM("Galaxy S3", "Samsung"); gsm.AddCall(846022, 150); gsm.AddCall(35956, 132); Console.WriteLine(gsm.CallsPrice(0.37m)); }
static void Main(string[] args) { // GSM 1 GSM nokia = new GSM("Nokia", "Nokia", 15, "Nokia"); // Add Calls Call c1 = new Call("11/14/2001","14:27:36","+123456",900); Call c2 = new Call("11/19/2001","14:56:36","+359883442324",800); Call c3 = new Call("11/19/2001","12:27:36","+359883442324",800); nokia.AddCall(c1); nokia.AddCall(c2); nokia.AddCall(c3); // Display Calls Info nokia.PrintCallHistory(); // Display Total Price of All Calls Console.WriteLine("Total Price of All Calls:{0:C2}", nokia.CallsTotalPrice(0.37m)); // Remove Call nokia.RemoveCall(c1); Console.WriteLine("Total Price of All Calls:{0:C2}", nokia.CallsTotalPrice(0.37m)); // Clear Call History nokia.RemoveAllCalls(); nokia.PrintCallHistory(); }
static void Main() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; GSM gsm = new GSM("htc one", "HTC"); gsm.AddCall(new Call(DateTime.Now, "0897213421", 430)); gsm.AddCall(new Call(DateTime.Now, "0882345233", 630)); gsm.AddCall(new Call(DateTime.Now, "0882332432", 930)); foreach (var call in gsm.CallHistory) { Console.WriteLine("Date: {0}",call.Date); Console.WriteLine("Time: {0}",call.Time); Console.WriteLine("Number: {0}",call.DialledPhoneNumber); Console.WriteLine("Duration: {0}",call.Duration); Console.WriteLine("----------------------------"); } decimal totalPriceCalls = gsm.CalcCallsTotalPrice(0.37m); Console.WriteLine(totalPriceCalls); int longestDuration = gsm.CallHistory.Max(c => c.Duration); Call longestCall = gsm.CallHistory.FirstOrDefault(c => c.Duration == longestDuration); gsm.CallHistory.Remove(longestCall); totalPriceCalls = gsm.CalcCallsTotalPrice(0.37m); Console.WriteLine(totalPriceCalls); gsm.ClearCallHistory(); }
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() { GSM gsmTest = new GSM("Nokia", "E7"); gsmTest.Owner = "Me"; gsmTest.Price = 680; gsmTest.battery.HoursIdle = 90f; gsmTest.battery.Model = "BL-4"; gsmTest.battery.Type = BatteryType.NiCd; gsmTest.battery.HoursTalk = 8.33f; gsmTest.display.ColoursCount = 16000000; gsmTest.display.Size = 4; gsmTest.call.DialedNumber = "654135416516"; gsmTest.call.DurationInSeconds = 123; gsmTest.AddCall(new Call("number+3590000", 120)); gsmTest.AddCall(new Call("number+3590001", 25)); gsmTest.AddCall(new Call("number+3590002", 0)); // gsmTest.PrintSpecs(); Console.WriteLine(gsmTest.ToString()); // Console.WriteLine(gsmTest.call.DurationInSeconds); // gsmTest.DeleteCall(1); // gsmTest.ClearCall(); for (int i = 0; i < gsmTest.CallHistory.Count; i++) { Console.WriteLine(gsmTest.CallHistory[i].DurationInSeconds); } Console.WriteLine("Total price of the call on phone {0} {1} is : {2}", gsmTest.Manufacturer, gsmTest.Model, gsmTest.GetTotalPriceOfCalls(0.18, gsmTest)); Console.WriteLine(GSM.Iphone4S.battery.Model); // Console.WriteLine(gsmTest.call.DurationInSeconds); }
static void Main(string[] args) { try { //Create battery and display for the GSM Battery battery = new Battery("BL-5C",360,7,Battery.BatteryType.LithiumLon); Display display = new Display(3,65536); //Create GSM GSM gsm = new GSM("1208", "nokia", 50, "Georgi", battery, display); //Console.WriteLine(gsm.ToString()); //Print GSM data //Mace some calls and print the history gsm.AddCall(new Call(new DateTime(2013, 02, 22, 19, 01, 22), "00359888888888", 200)); gsm.AddCall(new Call(new DateTime(2013,02,22,20,02,33),"0887888888",302)); gsm.AddCall(new Call(new DateTime(2013, 02, 22, 20, 30, 19), "0889-88-88-88", 178)); gsm.PrintCallHistiry(); //Calculate the price of all calls decimal price = 0.37m; gsm.CalculateTotalCallsPrice(price); //Remove the longest call and calculate the price again gsm.DeleteCall(1); //The calls in the list start from 0, so the second call(longest) is 1 gsm.CalculateTotalCallsPrice(price); //Clear the history and print it gsm.ClearCallHistory(); gsm.PrintCallHistiry(); } catch (Exception ex) { Console.WriteLine("Error!"+ex.Message); } }
public static void TestCallHistory() { // Initializing batteries and displays outside of the GSM constructors, // as the constructors should not initialize anyhting (good practice). var battery = new Battery("Toshiba", BatteryType.Li_Ion, 15, 10); var display = new Display(5.2, 24000); var phone = new GSM("Galaxy S7", "Samsung", 700, "Pesho", battery, display); phone.AddCall(new Call(DateTime.Now, "0999999999", 60)); phone.AddCall(new Call(new DateTime(2016, 7, 12, 23, 58, 30), "0444444444", 60)); phone.AddCall(new Call(new DateTime(2016, 3, 2, 5, 50, 40), "0888888888", 120)); Console.WriteLine("CALL HISTORY:"); Console.WriteLine(phone.DisplayCallHistory() + "\n"); Console.WriteLine("TOTAL PRICE: {0:C2}", phone.GetPrice()); Console.WriteLine(new string ('-', 20)); // Removing longest call and re-calculating price var longestCallIndex = 0; for (int i = 1; i < phone.CallHistory.Count; i++) { if (phone.CallHistory[i].Duration > phone.CallHistory[i - 1].Duration) { longestCallIndex = i; } } phone.DeleteCall(longestCallIndex); Console.WriteLine("MODIFIED CALL HISTORY:"); Console.WriteLine(phone.DisplayCallHistory() + "\n"); Console.WriteLine("NEW TOTAL PRICE: {0:C2}", phone.GetPrice()); }
public void GSMInitialize() { Battery zenfoneBattery = new Battery(null, 720, 200, BatteryType.LiPo); Display zenfoneDisplay = new Display(5.2, 16000000); phones = new GSM[] { projectAra = new GSM("ProjectAra", "Google", 100m, "Sundar Pichai"), iphone7 = new GSM("Iphone7", "Apple", 695m, "Steve Jobs", 21, BatteryType.LiIon), Mi5 = new GSM("Xiaomi Mi5", "Xiaomi", 449m, "Lei Jun", 5.15, 16000000), Zenfone3 = new GSM("Asus Zenfone3", "Asus", 305m, "Jerry Shen", zenfoneBattery, zenfoneDisplay), }; // call list projectAra.AddCall(20); projectAra.AddCall(50); projectAra.AddCall(15); projectAra.AddCall(17); iphone7.AddCall(30); iphone7.AddCall(5); iphone7.AddCall(10); Mi5.AddCall(40); Mi5.AddCall(33); Zenfone3.AddCall(60); Zenfone3.AddCall(120); }
public static void Test() { // create new GSM instance var huawei = new GSM( "Ascend G600", "Huawei", "Mtel", new Display(4.5, Display.ColorDepth._32Bit), new Battery("Toshiba-tbsae", 380, 6, Battery.Type.LiPol), 600); // add some calls to list of calls huawei.AddCall("0888124122", 210); huawei.AddCall("0888124122", 40); huawei.AddCall("0888124122", 80); huawei.AddCall("0919125121", 600); huawei.AddCall("0919125121", 10); huawei.ShowCalls(); // Print the call list // Calculate the price of the each call Console.WriteLine("The price of all calls is {0} ", huawei.CalculatePriceOfCalls(0.32m)); huawei.RemoveLongestCall(); huawei.ClearCallHistory(); huawei.ShowCalls(); }
public static void Test() { try { GSM Samsung = new GSM("Samsung S4", "Samsung", 1200, "Ivan", BatteryTypes.Lilon, 140, 23, 4.7, 512000); Samsung.AddCall(new Call("28.8.2013", "14:12:12", "+359125135123", 234)); Samsung.AddCall(new Call("23.8.2013", "14:12:12", "+359125135123", 54)); Samsung.AddCall(new Call("22.8.2013", "12:12:12", "+359125135123", 5234)); Samsung.AddCall(new Call("25.8.2013", "19:12:12", "+359125135123", 34)); Samsung.AddCall(new Call("22.8.2013", "14:0:12", "+359125135123", 2234)); Console.WriteLine("Call history:"); foreach (Call call in Samsung.CallHistory) { Console.WriteLine(call.ToString()); } Console.WriteLine("\nTotal price of calls:" + Samsung.CalculateTotalPrice().ToString() + " lv"); Samsung.DeleteCall(new Call("22.8.2013", "12:12:12", "+359125135123", 5234)); Console.WriteLine("\nTotal price of calls after removing longest call:" + Samsung.CalculateTotalPrice().ToString() + " lv"); Samsung.ClearCallHistory(); Console.WriteLine("\nCall history after clearing it:"); foreach (Call call in Samsung.CallHistory) { Console.WriteLine(call.ToString()); } } catch (Exception e) { Console.WriteLine(e.Message); } }
public static void RunTest() { GSM myPhone = new GSM("HTC Desire", "HTC", 550, "Pesho", new Battery(BatteryType.LiIon), new Display(4, 250000)); myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(5), "0887776987"); myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(8), "0897556644"); myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(15), "0887441100"); myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(23), "0885001122"); myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(4), "0896559988"); Console.WriteLine(myPhone); Console.WriteLine("-----------Call History-----------"); foreach (Call call in myPhone.CallHistory) { Console.WriteLine(call); } Console.WriteLine("Total price of all calls: ${0:F2}", myPhone.TotalCallsCost(0.37)); myPhone.DeleteLongestCall(); Console.WriteLine("After the remove of the longest call the total price is: ${0:F2}", myPhone.TotalCallsCost(0.37)); Console.WriteLine(); myPhone.ClearHistory(); Console.WriteLine("-----------Cleared Call History-----------"); if (myPhone.CallHistory.Count == 0) { Console.WriteLine("There are no Recorded Calls in the History!"); } else { foreach (Call call in myPhone.CallHistory) { Console.WriteLine(call); } } }
static void Main() { GSM NokiaN92 = new GSM("Nokia", "N82", 190, "Pesho Gosho", new Battery(Battery.Type.NiCD, 150, 13.5), new Display(2.5, 2000000000)); Console.WriteLine("Add some calls..."); NokiaN92.AddCall("0892023111", 250, 2013, 2, 25, 21, 9, 3); NokiaN92.AddCall("0892023111", 50, 2013, 2, 22, 12, 2, 30); NokiaN92.AddCall("0892023111", 110, 2013, 1, 7, 18, 3, 12); Console.WriteLine("Print the calls:"); foreach (var item in NokiaN92.CallHistory) { Console.WriteLine(item); } Console.WriteLine("Calculate price of calls if the price per minute is 0.37: {0}", NokiaN92.TotalCallsPrice((decimal)0.37)); Console.WriteLine("Deleting longest call duration with the method .DeleteCall(Call)"); NokiaN92.DeleteCall(NokiaN92.CallHistory[0]); Console.WriteLine("Calculate price of calls if the price per minute is 0.37: {0}", NokiaN92.TotalCallsPrice((decimal)0.37)); Console.WriteLine("Clear the CallHistory and print it:"); NokiaN92.ClearCallHistory(); foreach (var item in NokiaN92.CallHistory) { Console.WriteLine(item); } }
public static void Start() { // TODO GSM phone = new GSM("Pixel", "Google"); phone.AddCall("+359 123-456", new DateTime(2018, 7, 22), new TimeSpan(0, 1, 15)); phone.AddCall("089123456", new DateTime(2018, 6, 17), new TimeSpan(0, 3, 20)); phone.AddCall("+12 3123 121", new DateTime(2017, 1, 22), new TimeSpan(1, 5, 0)); foreach (Call call in phone.CallHistory) { Console.WriteLine($"Phone: {call.PhoneNumber}, Call Date: {call.Date}, Duration: {call.Duration}"); } PrintBill(phone); // Remove longest call from history Call longestCall = new Call("", new DateTime(), new TimeSpan(-1)); foreach (Call call in phone.CallHistory) { if (call.Duration.Seconds > longestCall.Duration.Seconds) { longestCall = call; } } phone.DeleteCall(longestCall); PrintBill(phone); }
static void Main(string[] args) { try { //Create battery and display for the GSM Battery battery = new Battery("BL-5C", 360, 7, Battery.BatteryType.LithiumLon); Display display = new Display(3, 65536); //Create GSM GSM gsm = new GSM("1208", "nokia", 50, "Georgi", battery, display); //Console.WriteLine(gsm.ToString()); //Print GSM data //Mace some calls and print the history gsm.AddCall(new Call(new DateTime(2013, 02, 22, 19, 01, 22), "00359888888888", 200)); gsm.AddCall(new Call(new DateTime(2013, 02, 22, 20, 02, 33), "0887888888", 302)); gsm.AddCall(new Call(new DateTime(2013, 02, 22, 20, 30, 19), "0889-88-88-88", 178)); gsm.PrintCallHistiry(); //Calculate the price of all calls decimal price = 0.37m; gsm.CalculateTotalCallsPrice(price); //Remove the longest call and calculate the price again gsm.DeleteCall(1); //The calls in the list start from 0, so the second call(longest) is 1 gsm.CalculateTotalCallsPrice(price); //Clear the history and print it gsm.ClearCallHistory(); gsm.PrintCallHistiry(); } catch (Exception ex) { Console.WriteLine("Error!" + ex.Message); } }
public static void Main(string[] args) { GSM phones = new GSM("Samsung", "GalaxyS", 500.00m, "John", "Smith", "Li-Ion", 730, 16, BatteryType.LiIon, 6d, 2000000); phones.AddCall(DateTime.Now.AddDays(-120.258), "+359 (87) 820 7979", 145); phones.AddCall(DateTime.Now, "+359 (88) 853 5280", 60); phones.AddCall(DateTime.Now.AddDays(35.086), "+359 (86) 315 7000", 80); phones.AddCall(DateTime.Now.AddDays(35.128), "+359 (2) 891 4868", 28); PrintCallHistory(phones); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; decimal callsPrice = phones.CallPriceCalculate(callPricePerMinute); Console.WriteLine(); Console.WriteLine("Total calls price {0:C2}\n", callsPrice); RemoveLongestCall(phones); Console.WriteLine("Longest call removed"); callsPrice = phones.CallPriceCalculate(callPricePerMinute); Console.WriteLine("Total calls price now is {0:C2}\n", callsPrice); phones.ClearCallsHistory(); PrintCallHistory(phones); }
//Fills the GSM with some random calls public static GSM FillGSMCalls(GSM currentGSM) { currentGSM.AddCall(new Call(40, DateTime.Now, "0888 888 888")); currentGSM.AddCall(new Call(190, DateTime.Now, "0888 888 888")); currentGSM.AddCall(new Call(130, DateTime.Now, "0888 888 888")); return(currentGSM); }
public static void Init() { testInstance = new GSM("Nokia", "Nokia INC", 123.45m, "Pesho Peshev"); GSM.IPhone4S = "IPhone4S characteristics."; testInstance.AddCall(new Call("0894121212", 233)); testInstance.AddCall(new Call("0898121555", 2333)); testInstance.AddCall(new Call("0897121265", 12)); }
static void Main() { // GSMTest GSM[] test = new GSM[3]; Display testDisplay = new Display(12, 13); Battery testBattery = new Battery(BatteryType.LiIon, 10, 10); GSM firstPhone = new GSM("test", "test", 12, "Shefa Joro", testBattery, testDisplay); test[0] = firstPhone; GSM secondPhone = new GSM("SecondTest", "SecondTest", 14, "Moore Name", testBattery, testDisplay); test[1] = secondPhone; GSM thirdPhone = new GSM("Some test", "Texttt", 1, "Name", testBattery, testDisplay); test[2] = thirdPhone; for (int i = 0; i < test.Length; i++) { Console.WriteLine(test[i]); } Console.WriteLine(GSM.Iphone.Model); Console.WriteLine(GSM.Iphone.Manufacturer); Console.WriteLine(firstPhone.Battery.BatteryModel); Console.WriteLine("---------------------------------"); Console.WriteLine("GSMCallHistoryTest"); Console.WriteLine("---------------------------------"); //GSMCallHistoryTest GSM myPhone = new GSM("Nokia", "Nokia Corp", 1, "Ivan", testBattery, testDisplay); myPhone.AddCall(DateTime.Now, "088888888", 236); myPhone.AddCall(DateTime.Now, "077777777", 333); myPhone.AddCall(DateTime.Now, "066666666", 123); myPhone.AddCall(DateTime.Now, "055555555", 11); myPhone.AddCall(DateTime.Now, "044444444", 23); myPhone.DisplayCallHistory(); Console.WriteLine(myPhone.CalcPrice(0.37)); myPhone.RemoveCallByDuration(333); myPhone.DisplayCallHistory(); Console.WriteLine(myPhone.CalcPrice(0.37)); myPhone.ClearHistory(); myPhone.DisplayCallHistory(); }
static void Main() { GSM nokia = new GSM("N73", "Nokia", "Pesho", 360, new Battery("BP-6M", 370, 6, BatteryType.LiIon), new Display(2.4, 243000)); GSM samsung = new GSM("GalaxyS III", "Samsung", "Gosho", 819, new Battery("HR32", 790, 50, BatteryType.LiIon), new Display(4.8, 16000000)); GSM sonyEricsson = new GSM("Xperia Z", "Sony Ericsson", "Kiro", 864, new Battery("PM63", 550, 40, BatteryType.LiIon), new Display(5, 16000000)); GSM vertu = new GSM("Ascent", "Vertu", "Dimcho", 10400, new Battery("RP-M4", 150, 4, BatteryType.LiIon), new Display(0.87, 6)); GSM[] mobilePhones = { nokia, samsung, sonyEricsson, vertu, GSM.IPhone4S }; foreach (var phone in mobilePhones) { Console.WriteLine(phone); Console.WriteLine("------------------------------"); } Call callOne = new Call("0885131618", 125); Call callTwo = new Call("0886933601", 563); Call callThree = new Call("0886948266", 256); vertu.AddCall(callOne); vertu.AddCall(callTwo); vertu.AddCall(callThree); Console.WriteLine("Total price of all calls: {0}", vertu.CalcPriceOfCalls(0.37)); double maxDuration = 0; string number = ""; foreach (var call in vertu.CallHistory) { if (maxDuration < call.Duration) { maxDuration = call.Duration; number = call.DialedPhoneNumber; } } Call longestCall = new Call(number, maxDuration); Console.WriteLine("The longest call lasted {0} seconds and it is made with number {1}.", maxDuration, number); vertu.DeleteCall(longestCall); Console.WriteLine("Now the longest call is removed from the call history."); Console.WriteLine("New total price of all calls: {0}", vertu.CalcPriceOfCalls(0.37)); vertu.ClearCallHistory(); Console.WriteLine("Call history is now cleared!!!"); }
static void Main() { GSM nokia = new GSM("N7", "Nokia"); nokia.AddCall(360); nokia.AddCall(500); nokia.AddCall(1500); nokia.DisplayCalls(); Console.WriteLine("The total price of the calls with 0.37st/min is {0}", nokia.CallPrice(0.37)); nokia.DeleteCall(1500); nokia.DisplayCalls(); Console.WriteLine("The total price of the calls without the longest call is {0}", nokia.CallPrice(0.37)); }
static void Main() { // GSMTest GSM[] test = new GSM[3]; Display testDisplay = new Display(12, 13); Battery testBattery = new Battery(BatteryType.LiIon, 10, 10); GSM firstPhone = new GSM("test", "test", 12, "Bai Ivan", testBattery, testDisplay); test[0] = firstPhone; GSM secondPhone = new GSM("SecondTest", "SecondTest", 14, "Moore Name", testBattery, testDisplay); test[1] = secondPhone; GSM thirdPhone = new GSM("Some test", "Texttt", 1, "Name", testBattery, testDisplay); test[2] = thirdPhone; for (int i = 0; i < test.Length; i++) { Console.WriteLine(test[i]); } Console.WriteLine(GSM.Iphone.Model); Console.WriteLine(GSM.Iphone.Manufacturer); Console.WriteLine(firstPhone.Battery.BatteryModel); Console.WriteLine("---------------------------------"); Console.WriteLine("GSMCallHistoryTest"); Console.WriteLine("---------------------------------"); //GSMCallHistoryTest GSM myPhone = new GSM("Nokia", "Nokia Corp", 1, "Ivan", testBattery, testDisplay); myPhone.AddCall(DateTime.Now, "088888888", 236); myPhone.AddCall(DateTime.Now, "077777777", 333); myPhone.AddCall(DateTime.Now, "066666666", 123); myPhone.AddCall(DateTime.Now, "055555555", 11); myPhone.AddCall(DateTime.Now, "044444444", 23); myPhone.DisplayCallHistory(); Console.WriteLine(myPhone.CalcPrice(0.37)); myPhone.RemoveCallByDuration(333); myPhone.DisplayCallHistory(); Console.WriteLine(myPhone.CalcPrice(0.37)); myPhone.ClearHistory(); myPhone.DisplayCallHistory(); }
static void Main() { GSM phone1 = new GSM("Samsung", "Germany", 1000); GSM phone2 = new GSM("Nokia", "Italy", 200.99m, "Boris"); GSM phone3 = GSM.IPhone4S; GSM[] phones = new GSM[] { phone1, phone2, phone3 }; Call newCall1 = new Call("05.03.2013", "0882203628", 100); Call newCall2 = new Call("01.02.2013", "11:00", "0882203628", 60); Call newCall3 = new Call("0882203628", 10); Call newCall4 = new Call("08.03.2013", "21:00", "0882203628", 360); phone1.AddCall(newCall1); phone1.AddCall(newCall2); phone1.AddCall(newCall3); phone1.AddCall(newCall4); //Print CallHistory StringBuilder result = new StringBuilder(); foreach (var call in phone1.CallHistory) { result.AppendFormat("Date: {0}\nTime: {1}\nDialedNumber: {2}\nDuration (in seconds): {3}\n\n", call.date, call.time, call.dialedPnoneNumber, call.duration); } Console.WriteLine(result.ToString()); //Calculate TotalPrice decimal price = phone1.TotalPrice(0.37m); Console.WriteLine("{0:F2}лв.", price); //Calculate TotalPrice without long call phone1.DeleteCall(newCall4); decimal priceWithoutLongCall = phone1.TotalPrice(0.37m); Console.WriteLine("{0:F2}лв.", priceWithoutLongCall); //Clear CallHistory phone1.ClearCallHistory(); StringBuilder resultClear = new StringBuilder(); foreach (var call in phone1.CallHistory) { resultClear.AppendFormat("Date: {0}\nTime: {1}\nDialedNumber: {2}\nDuration (in seconds): {3}\n\n", call.date, call.time, call.dialedPnoneNumber, call.duration); } Console.WriteLine(); Console.WriteLine("The result after clear is: \n", resultClear.ToString()); }
static void Main() { System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; GSM gsm = new GSM("Galaxy S3", "Samsung"); gsm.AddCall(846022, 150); gsm.AddCall(35956, 132); gsm.PrintCalls(); Console.WriteLine("-------------"); gsm.RemoveCall(35956); gsm.PrintCalls(); Console.WriteLine("-------------"); gsm.AddCall(654213, 32); gsm.ClearHistory(); gsm.PrintCalls(); }
static void Main() { Battery newBattery = new Battery(BatteryType.LiIon, "ChinaBattery", 10, 10); Display newDisplay = new Display(4.0, 16000000); GSM[] gsms = new GSM[2]; gsms[0] = new GSM("iPhone5", "Apple", 1500, "Steve Jobs", newBattery, newDisplay); gsms[1] = new GSM("Galaxy Ace", "Samsung", 500, "Lee Byung-chull", newBattery, newDisplay); Console.WriteLine(gsms[0]); Console.WriteLine(gsms[1]); Console.WriteLine("Iphone Model: {0}", GSM.IPhone4S.Model); Console.WriteLine("Iphone Manufacturer: {0}", GSM.IPhone4S.Manufacturer); Console.WriteLine("Iphone Price: {0}", GSM.IPhone4S.Price); //Task 12 Console.WriteLine(); Console.WriteLine("---------------------------------------"); Console.WriteLine(); GSM nokiaPhone = new GSM("C6-01", "Nokia", 400, "Nokia owner", newBattery, newDisplay); nokiaPhone.AddCall(DateTime.Now, 359888123456, 120); nokiaPhone.AddCall(DateTime.Now, 359884000000, 240); nokiaPhone.AddCall(DateTime.Now, 359882000000, 480); int longestCall = 0; int longestDuration = 0; for (int i = 0; i < nokiaPhone.CallHistory.Count; i++) { if (nokiaPhone.CallHistory[i].DurationInSeconds > longestDuration) { longestDuration = nokiaPhone.CallHistory[i].DurationInSeconds; longestCall = i; } Console.WriteLine("Call from {0} to {1} lasted {2} seconds", nokiaPhone.CallHistory[i].Date, nokiaPhone.CallHistory[i].DialedPhoneNumber, nokiaPhone.CallHistory[i].DurationInSeconds); } Console.WriteLine(); Console.WriteLine("Total calls cost is {0}lv.", nokiaPhone.TotalCallPrice(0.37)); nokiaPhone.RemoveCall(longestCall); Console.WriteLine("Total calls cost after deleting the longest call is {0}lv.", nokiaPhone.TotalCallPrice(0.37)); nokiaPhone.ClearCalls(); }
public static void Main() { Battery lionBattery = new Battery("Lion", BatteryType.LiIon, 49, 8); Display bigDisplay = new Display(4.7, 16000000); GSM phone = new GSM("Galaxy", "Samsung", 400.78M, "Pesho", lionBattery, bigDisplay); Call currentCall = new Call(DateTime.Now.AddDays(6), "0888888888", 156); phone.AddCall(currentCall); currentCall = new Call(DateTime.Now, "0777777777", 456); phone.AddCall(currentCall); currentCall = new Call(DateTime.Now.AddHours(100), "0989565690", 345); phone.AddCall(currentCall); foreach (var call in phone.CallHistory) { Console.WriteLine("Call date:{0} Phone number:{1} Duration:{2} seconds", call.Date, call.DialledPhoneNumber, call.DurationInSeconds); } Console.WriteLine("Total call price is: ${0}", phone.CalculateTotalCallPrice()); long?maxCallDuration = long.MinValue; Call longestCall = new Call(DateTime.Now, "00000000", 0); foreach (var currentCallToCheck in phone.CallHistory) { if (currentCallToCheck.DurationInSeconds > maxCallDuration) { maxCallDuration = currentCallToCheck.DurationInSeconds; longestCall = currentCallToCheck; } } phone.RemoveCall(longestCall); Console.WriteLine("Total price without longest call: $" + phone.CalculateTotalCallPrice()); phone.ClaerCallHistory(); if (phone.CallHistory.Count == 0) { Console.WriteLine("Calls cleared!"); } }
public static void GSMCallHistoryStartTest() { Console.WriteLine("Call history test"); DrawLine('-'); var testGsm = new GSM("iPhone 18s", "Apple", 1800m, "Batman"); Random rndCallLengthGen = new Random(); Random rndNumberGen = new Random(); for (int i = 0; i < 10; i++) { string number = "+359" + rndNumberGen.Next(82000001, 90000000); uint callDuration = (uint)rndCallLengthGen.Next(8, 361); var call = new Call(callDuration, number); testGsm.AddCall(call); } PrintCallHistory(testGsm); Console.WriteLine("Total calls price: {0:f2}", testGsm.GetCallsPrice(0.37m)); Call logestCall = testGsm.CallHistory.OrderByDescending(c => c.Duration).FirstOrDefault(); testGsm.DeleteCall(logestCall); Console.WriteLine("Total calls price after deleting the longest call: {0:f2}", testGsm.GetCallsPrice(0.37m)); testGsm.ClearCallHistory(); PrintCallHistory(testGsm); }
static void Main() { List <GSM> cellPhones = new List <GSM>(); GSM currentGSM = new GSM("Galaxy SIV", "Samsung", 999.99, "Ganka", new Battery("normal", BatteryType.LiIon, 500, 250), new Display("5.0\"", 16000000)); cellPhones.Add(currentGSM); currentGSM = new GSM("One", "HTC", 949.99, "Tosho"); cellPhones.Add(currentGSM); currentGSM = new GSM("Lumia", "Nokia", 799.99, "test", new Battery("duracell", BatteryType.NiMh)); cellPhones.Add(currentGSM); foreach (var phone in cellPhones) { Console.WriteLine(phone.ToString()); } Console.WriteLine(GSM.IPhone4S.ToString()); currentGSM.AddCall(DateTime.Now, "0883412079", 75); Console.WriteLine(currentGSM.CalculateTotalCallPrice(0.50m)); }
public static void Main(string[] args) { // Task 4 GSM testGsm = new GSM("3310", "Nokia", 99.99m, "Pesho", "Nokia Battery", default(BatteryType), "14:45:00", "19:30:00", 2.4f, 8); Console.WriteLine(testGsm + "\n"); // Task 5 Console.WriteLine(GSM.Iphone4S + "\n"); // Task 7 GSM[] gsmArray = new GSM[5]; for (int index = 0; index < gsmArray.Length; index++) { gsmArray[index] = new GSM( string.Format("TestGsm{0}", index), string.Format("Manufacturer{0}", index), index * 100, string.Format("Owner{0}", index), string.Format("Type{0}", index), default(BatteryType)); } foreach (var gsm in gsmArray) { Console.WriteLine(gsm + "\n"); } // Task 10 testGsm.AddCall(new DateTime(2013, 02, 25), "977 977 456", 45); testGsm.AddCall(new DateTime(2013, 02, 27), "966 968 945", 54); testGsm.AddCall(); testGsm.AddCall(new DateTime(2013, 02, 28), "977 555 080", 10); testGsm.DeleteCall(2); // Task 11 Console.WriteLine(testGsm.CallHistory); Console.WriteLine("Total price of calls {0:0.00}$", testGsm.TotalPrice()); // Task 12 testGsm.RemoveLongestCall(); Console.WriteLine("Total price of calls {0:0.00}$", testGsm.TotalPrice()); testGsm.ClearCallHistory(); Console.WriteLine(testGsm.CallHistory); }
static GSM AddCalls(GSM gsmTwo, int numberOfCalls) { for (int i = 1; i <= numberOfCalls; i++) { gsmTwo.AddCall(); } return(gsmTwo); }
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 public void Print() { GSM phone = new GSM("galaxy", "samsung"); string date1 = "07/07/2011 10:48:12"; string date2 = "17/03/2012 08:43:08"; string date3 = "08/06/2012 02:52:24"; Call call1 = new Call(ParseDate(date1).ToString("dd/MM/yyyy"), ParseDate(date1).ToString("hh:mm:ss"), 0898456456, 450); Call call2 = new Call(ParseDate(date2).ToString("dd/MM/yyyy"), ParseDate(date2).ToString("hh:mm:ss"), 0898324456, 350); Call call3 = new Call(ParseDate(date3).ToString("dd/MM/yyyy"), ParseDate(date3).ToString("hh:mm:ss"), 0898324879, 620); Console.WriteLine(call1); Console.WriteLine(new string('-', 20)); Console.WriteLine(call2); Console.WriteLine(new string('-', 20)); Console.WriteLine(call3); phone.AddCall(call1); phone.AddCall(call2); phone.AddCall(call3); decimal sum = phone.CalculateTotalPriceOfCalls(phone.CallHistory); Console.WriteLine("price of all calls in History is {0}", sum); ulong maxDuration = 0; int maxIndex = -1; for (int i = 0; i < phone.CallHistory.Count; i++) { if (maxDuration < phone.CallHistory[i].Duration) { maxDuration = phone.CallHistory[i].Duration; maxIndex = i; } } phone.DeleteCall(phone.CallHistory[maxIndex]); sum = phone.CalculateTotalPriceOfCalls(phone.CallHistory); Console.WriteLine("price of all calls in History is {0}", sum); phone.ClearCallHistory(); Console.WriteLine("there are {0} calls in call history", phone.CallHistory.Count); //Console.WriteLine(call1.Date + " " + call1.Time + " " + call1.DialedNumber + " " + call1.Duration); }
static void Main(string[] args) { GSM nokia = new GSM("lumia", "nokia", 900, "Stoyan", new Battery("Asperji", 30, 0, Battery.BatteryType.NiMH), new Display("366x512", 16000000)); nokia.AddCall(new Call("02.04.2015", "02:22:32", "0884239123", (long)340)); nokia.AddCall(new Call("01.10.2015", "12:12:42", "0884232345", (long)245)); nokia.AddCall(new Call("02.04.2015", "15:33:12", "0889123242", (long)45)); //display info for each call foreach (var call in nokia.callHistory) { Console.WriteLine(call.ToString()); Console.WriteLine(); } //total price of calls Console.WriteLine("Total price of all calls (0.37 per minute) : " + nokia.TotalPriceOfCalls(0.37m)); Console.WriteLine(); long? max = 0; Call c = new Call(); foreach (Call call in nokia.callHistory) { if (call.Duration > max) { max = call.Duration; c = call; } } nokia.callHistory.Remove(c); Console.WriteLine("Total price of all calls after removal (0.37 per minute) : " + nokia.TotalPriceOfCalls(0.37m)); nokia.callHistory.Clear(); //print after removal of all elements foreach (var call in nokia.callHistory) { Console.WriteLine(call); } Console.WriteLine(); }
static void Main() { GSM phone = new GSM("Z3", "Sony", 990, "Pippi Longstocking", "Sony 3100mAh", 93.8, 52.9, BatteryType.LiIon, 5.2, 16000000); phone.AddCall(new Call(DateTime.Now, "+359 (0) 894 733 124", 287)); phone.AddCall(new Call(DateTime.Now, "+359 (0) 894 788 134", 123)); phone.AddCall(new Call(DateTime.Now.AddDays(-12), "+359 (0) 894 733 114", 90)); PrintCallHistory(phone); Console.WriteLine("The total price of all calls of {0} is {1} EUR!", phone.Owner, CalculateTotalCallPrice(phone.CallHistory, callPricePerMinute)); Console.WriteLine("The total price of all calls without the longest call of {0} is {1} EUR!", phone.Owner, CalculateTotalCallPrice(RemoveLongestCall(phone.CallHistory), callPricePerMinute)); phone.ClearCallHistory(); PrintCallHistory(phone); }
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); } }
//12.Write a class GSMCallHistoryTest to test the call history functionality of the GSM class. //-Create an instance of the GSM class. //-Add few calls. //-Display the information about the calls. //-Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history. //-Remove the longest call from the history and calculate the total price again. //-Finally clear the call history and print it. static void Main() { const decimal callPerMinutePrice = 0.37M; GSM phone = new GSM("Galaxy S2", "Samsung", 450, "Gogo", new Battery("A1920", BatteryType.LiIon), new Display(3.2M, 100000UL)); phone.AddCall(new Call("29.02.2012", "10:10:10", "0845333444", 60)); phone.AddCall(new Call("15.12.2013", "12:00:00", "0879123456", 480)); phone.AddCall(new Call("20.07.2011", "15:00:00", "0863123456", 960)); //print every call information foreach (Call call in phone.CallHistory) { Console.WriteLine(call.ToString()); Console.WriteLine(); } decimal phoneCallsPrice = phone.CalculateCallsPrice(callPerMinutePrice); Console.WriteLine("Total cost of all calls: {0}", phoneCallsPrice); Console.WriteLine(); phone.DeleteCall(2); phoneCallsPrice = phone.CalculateCallsPrice(callPerMinutePrice); Console.WriteLine("Total cost of all calls after deleted the longest call: {0}", phoneCallsPrice); Console.WriteLine(); //after the deleted call Console.ForegroundColor = ConsoleColor.Cyan; foreach (var call in phone.CallHistory) { Console.WriteLine(call.ToString()); Console.WriteLine(); } phone.ClearCallHistory(); //try to print calls, but history is deleted //there is no calls in the call history and nothing happens foreach (var call in phone.CallHistory) { Console.WriteLine(call.ToString()); Console.WriteLine(); } Console.ResetColor(); }
static void Main(string[] args) { //Create an instance of the GSM class. Battery phoneBattery = new Battery("NiCd", 30.6, 5.6); Display phoneDisplay = new Display(5.0, 16000000); GSM phone = new GSM("Galaxy Note", "Samsung", 866, "Goran Bregovic", phoneBattery, phoneDisplay); //Add few calls. DateTime dateAndTime = new DateTime(2013, 3, 5, 11, 59, 59); Call callOne = new Call(dateAndTime, "0888455455", 110); Call callTwo = new Call(dateAndTime, "0899455455", 50); Call callThree = new Call(dateAndTime, "0886455455", 230); phone.AddCall(callOne); phone.AddCall(callTwo); phone.AddCall(callThree); //Display the information about the calls. //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history. Console.WriteLine(phone.CallHistoryToString); double price = phone.CalculatePrice(0.37); Console.WriteLine("The price for the whole history is {0}", price); //Remove the longest call from the history and calculate the total price again. uint maxDuritation = uint.MinValue; Call callToRemove = new Call(dateAndTime, "0886455455", 0); for (int i = 0; i < phone.CallHistory.Count; i++) { if (phone.CallHistory[i].Duritation > maxDuritation) { maxDuritation = phone.CallHistory[i].Duritation; callToRemove = phone.CallHistory[i]; } } phone.DeleteCall(callToRemove); price = phone.CalculatePrice(0.37); Console.WriteLine("The new price after we removed the longest call is {0}", price); //Finally clear the call history and print it. Console.WriteLine(); Console.WriteLine("Clearing History..."); phone.ClearHistory(); Console.WriteLine("Call History: {0}", phone.CallHistoryToString); }
static void Main(string[] args) { var device = new GSM("Touch Pro 2", "HTC", "Vlado"); Call firstCall = new Call(180); device.AddCall(firstCall); Console.WriteLine(device.CallHystoryPrice()); }
public static void TestCallHistory() { GSM gsm = new GSM("Samsung Galaxy S Duos S7582", "Samsung", 100M, new Battery(BatteryTypes.LiIon, 310, 8), new Display(4, 16 * 1024)); Call call = new Call("0899798546", 100); gsm.AddCall(call); call = new Call("+35902364972", 50); gsm.AddCall(call); call = new Call("+35905235678", 1000); gsm.AddCall(call); Console.WriteLine("Information about the calls:"); Console.WriteLine(gsm.CallHistoryToString()); Console.WriteLine(); decimal price = gsm.CalculateCallHistoryPrice(0.37M); Console.WriteLine("Calls total price"); Console.WriteLine("{0:F2}", price); Console.WriteLine(); Call longestCall = gsm.CallHistory.OrderByDescending(x => x.Duration).FirstOrDefault(); if (longestCall != null) { gsm.DeleteCall(longestCall); Console.WriteLine("Longest call is removed."); } else { Console.WriteLine("Longest call is not found."); } price = gsm.CalculateCallHistoryPrice(0.37M); Console.WriteLine("Calls total price"); Console.WriteLine("{0:F2}", price); Console.WriteLine(); gsm.ClearCallHistory(); Console.WriteLine("Call history is cleared"); Console.WriteLine("Information about the calls:"); Console.WriteLine(gsm.CallHistoryToString()); }
public static void Test() { // create new GSM instance GSM Huawei = new GSM("Ascend G600", "Huawei", 600, "Mtel", new Display(4.5, Display.ColorDepth._32Bit), new Battery("Toshiba-tbsae", 380, 6, Battery.Type.LiPol)); // add some calls to list of calls Huawei.AddCall("0888124122", 210); Huawei.AddCall("0888124122", 40); Huawei.AddCall("0888124122", 80); Huawei.AddCall("0919125121", 600); Huawei.AddCall("0919125121", 10); Huawei.ShowCalls(); // Print the call list // Calculate the price of the each call Console.WriteLine("The price of all calls is {0} ", Huawei.CalculatePriceOfCalls(0.32m)); Huawei.RemoveLongestCall(); Huawei.ClearCallHistory(); Huawei.ShowCalls(); }
static void Main() { // Initialise an object to the already set static property GSM currentGSM = GSM.IPhone4S; // Add some calls currentGSM.AddCall(DateTime.Now, "12315123", 43); currentGSM.AddCall(DateTime.Now, "123156341", 27); currentGSM.AddCall(DateTime.Now, "080823874", 132); // Get the longest duration call and display details about each call int longestDurationIndex = int.MinValue; int longestDuration = int.MinValue; for (int i = 0; i < currentGSM.CallHistory.Count; i++) { Console.WriteLine(currentGSM.CallHistory[i].ToString()); Console.WriteLine(); if (currentGSM.CallHistory[i].Duration > longestDuration) { longestDurationIndex = i; longestDuration = currentGSM.CallHistory[i].Duration; } } // Calculate total call history price Console.WriteLine("{0:0.00}", currentGSM.CalculateTotalCallPrice(0.37m)); // Remove the longest duration call and recalculate the call history price currentGSM.DeleteCall(longestDurationIndex); Console.WriteLine("{0:0.00}", currentGSM.CalculateTotalCallPrice(0.37m)); // Clear the call history currentGSM.ClearHistory(); foreach (var call in currentGSM.CallHistory) { Console.WriteLine(call.ToString()); } }
public static void StartTest() { var display = new Display(3, 300); var battery = new Battery("S.NO.W3TT543"); GSM addPhone = new GSM("Hero", "HTC", 100m, "4ovek", battery, display); DateTime time = new DateTime(2013, 1, 10, 11, 00, 00); string number = "08837656282"; int duration = 60; addPhone.AddCall(time, number, duration); DateTime time1 = new DateTime(2013, 1, 10, 12, 00, 00); string number1 = "08957656282"; int duration1 = 135; addPhone.AddCall(time1, number1, duration1); DateTime time2 = new DateTime(2013, 1, 10, 12, 05, 00); string number2 = "08957656282"; int duration2 = 35; addPhone.AddCall(time2, number2, duration2); var callHistory = addPhone.CallHistory; Console.WriteLine(); foreach (var call in callHistory) { Console.WriteLine("Call: {0}\t{1}\t{2} secconds", call.Phone, call.Time, call.Duration); } Console.WriteLine("The bill is: {0}$", addPhone.Bill(0.37m)); callHistory = callHistory.OrderByDescending(x => x.Duration).ToList(); addPhone.DelCall(callHistory[0]); Console.WriteLine("After deleting the longest call the bill is: {0}$", addPhone.Bill(0.37m)); addPhone.ClearCallHistory(); Console.WriteLine("Printing call history (should be empty)"); callHistory = addPhone.CallHistory; foreach (var call in callHistory) { Console.WriteLine("Call: {0}\t{1}\t{2} secconds", call.Phone, call.Time, call.Duration); } }
public static void CallHistory() { GSM callTest = new GSM("3310", "Nokia", 10, "Stamat", new Battery(BatteryType.Unknown, 999999999, 99999999), new Display(1, 2)); callTest.AddCall(DateTime.Now, "0888888888", 360); callTest.AddCall(new DateTime(2016, 6, 6, 12, 35, 10), "0877777777", 956); callTest.AddCall(new DateTime(2016, 7, 6, 20, 10, 32), "0877777777", 1082); Console.WriteLine("Call history:"); Console.WriteLine(callTest.CallHistory); Console.WriteLine("Price for calls:"); Console.WriteLine("${0:F2}", callTest.GetPrice()); callTest.RemoveLongestCall(); Console.WriteLine("Price after removed longest call:"); Console.WriteLine("${0:F2}", callTest.GetPrice()); callTest.ClearHistory(); Console.WriteLine(callTest.CallHistory); }
public static void CallHistory() { GSM callTest = new GSM("Galaxy 5", "Samsung", 10, "Yordan Yordanov", new Battery(BatteryType.Unknown, 999999999, 99999999), new Display(1, 2)); callTest.AddCall(DateTime.Now, "+359888111222", 360); callTest.AddCall(new DateTime(2016, 5, 30, 07, 10, 14), "+359888123456", 601); callTest.AddCall(new DateTime(2016, 5, 31, 15, 10, 18), "+359888123456", 128); Console.WriteLine("Call history:"); Console.WriteLine(callTest.CallHistory); Console.WriteLine("Price for calls:"); Console.WriteLine("${0:F2}", callTest.GetPrice()); callTest.RemoveLongestCall(); Console.WriteLine("Price after removed longest call:"); Console.WriteLine("${0:F2}", callTest.GetPrice()); callTest.ClearHistory(); Console.WriteLine(callTest.CallHistory); }
public void GSMCalls_ShouldStoreZeroCallsAndCalculatePrice0() { Battery battery = new Battery("BL-5C", 200, 1700, BatteryType.LiIon); GSM phone = new GSM("Samsung", "Galaxy 4", 550.34f, "Dimitar", battery, 5.0f); phone.AddCall(new Call()); var result = phone.CalcCallsPrice(1.0f); float expected = 0.0f; Assert.AreEqual(expected, result, "Zero call should have price 0"); }
static void Main() { // Declare gsm GSM apple = new GSM("iPhone5s", "Apple"); // Directly add call, using inner initializer apple.AddCall(new Call(DateTime.Now, "0888 887766", 56)); apple.AddCall(new Call(new DateTime(2014, 1, 5, 13, 43, 16), "0877 997755", 93)); // Declare variable of type "Call" and add it to call history of gsm Call appleCall = new Call(new DateTime(2014, 1, 4, 16, 10, 37), "+359 888 112233", 347); apple.AddCall(appleCall); // Assign the array with all calls, returned by the propertie "CallHistory" Call[] appleCalls = apple.CallHistory; // Print all calls for (int i = 0; i < appleCalls.Length; i++) { Console.WriteLine(appleCalls[i]); } // Print current total price of all calls. // Method "ClalcTotalCallsPrice" take one parameter - price per minute Console.WriteLine("Total price: {0}", apple.ClalcTotalCallsPrice(0.37M)); // Delete longets duration call and print again the total cost of all calls apple.DeleteLongestCall(); Console.WriteLine("Total price after remove of longets call: {0}", apple.ClalcTotalCallsPrice(0.37M)); // Clear entire call history apple.ClearCallHistory(); // Once again get the call history, to see that it is empty appleCalls = apple.CallHistory; for (int i = 0; i < appleCalls.Length; i++) { Console.WriteLine(appleCalls[i]); } }
static void Main() { // just some sample tests GSM tel = new GSM("Nokia", "gosho tupoto", owner: "Pesho"); tel.AddCall("0885032502", new DateTime(2003, 2, 1), new TimeSpan(0, 10, 15)); tel.AddCall("0883456782", new DateTime(2003, 2, 1), new TimeSpan(0, 20, 15)); tel.AddCall("+359885032548", new DateTime(2003, 2, 1), new TimeSpan(0, 10, 15)); tel.AddCall("+359885032576", new DateTime(2003, 2, 1), new TimeSpan(0, 15, 15)); Console.WriteLine(tel.GetCost(0.37)); tel.RemoveCall(); tel.PrintHistory(); Console.WriteLine(tel.GetCost(0.37)); tel.ClearHistory(); tel.PrintHistory(); Console.WriteLine(tel + "\n\n\n"); // IPhone test Console.WriteLine(GSM.IPhone4S); }
static void Main() { GSM testPhone = new GSM("Lumia", "Microsoft"); testPhone.AddCall(new DateTime(2015, 1, 1), 0888123456, 50); testPhone.AddCall(new DateTime(2015, 1, 10), 0888123456, 50); testPhone.AddCall(DateTime.Now, 0888123456, 100); PrintCalls(testPhone.CallHistory); Console.WriteLine("Total price is {0}", testPhone.TotalCallsPrice(0.37)); int longestCallIndex = FindLongestCall(testPhone.CallHistory); testPhone.DeleteCall(longestCallIndex); Console.WriteLine("Total price after removal of longest call is {0}", testPhone.TotalCallsPrice(0.37)); testPhone.ClearCallHistory(); PrintCalls(testPhone.CallHistory); }
public static void CallTests() { Console.WriteLine("Creating an instance of GSM"); var gsm = new GSM("Bazooka", "Razni Imigrantï", new Battery(BatteryCellType.Experimental), new Display("Nai Golemiya", "Resprom", 7.2f, 5000000f)); Console.WriteLine("\n Generating 3 Calls"); gsm.AddCall(new Call(DateTime.Now, "0883 45 98 12", TimeSpan.Parse("0:00:5"))); gsm.AddCall(new Call(DateTime.Now, "0898 12 34 56", TimeSpan.Parse("0:10:0"))); gsm.AddCall(new Call(DateTime.Now, "0888 01 23 98", TimeSpan.Parse("1:05:15"))); Console.WriteLine("\nDisplaying Call information: "); foreach (Call call in gsm.CallHistory) { Console.WriteLine(call.GetCallInformation()); } Console.WriteLine("Calculation total call price based on {0:C} per minute tariff", pricePerMinute); Console.WriteLine("{0:C}", gsm.ReturnAllCallsCosts(pricePerMinute)); Console.WriteLine("\nRemoving the longest call and recalculation costs"); gsm.RemoveCall(2); Console.WriteLine("{0:C}", gsm.ReturnAllCallsCosts(pricePerMinute)); Console.WriteLine("Clearing call history"); gsm.ClearCallHistory(); foreach (Call call in gsm.CallHistory) { Console.WriteLine(call.GetCallInformation()); } }
static void Main(string[] args) { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; GSM NokiaGSM = new GSM("N-30", "Nokia", 180m, new Person("Gogo"), new Battery("825L", 123, 100, BatteryType.LiIon), new Display(15, 1024)); NokiaGSM.AddCall(new Call(DateTime.Now, "088888888", 156)); NokiaGSM.AddCall(new Call(DateTime.Now.AddDays(3), "0888888899", 12)); NokiaGSM.AddCall(new Call(DateTime.Now.AddHours(1), "0888888344", 100)); NokiaGSM.AddCall(new Call(DateTime.Now.AddHours(56), "088883443", 1500)); decimal maxDuration = NokiaGSM.CallHistory[0].DurationInSeconds; int positionMaxDurationCall = 0; for (int i = 0; i < NokiaGSM.CallHistory.Count; i++) { Console.WriteLine("{0} call {1}", i + 1, NokiaGSM.CallHistory[i]); Console.WriteLine(); if (NokiaGSM.CallHistory[i].DurationInSeconds > maxDuration) { maxDuration = NokiaGSM.CallHistory[i].DurationInSeconds; positionMaxDurationCall = i; } } Console.WriteLine(new string('-', 50)); Console.Write("The total price of your {0} calls is: ", NokiaGSM.CallHistory.Count); Console.WriteLine(NokiaGSM.CalculatePrice(0.37m)); NokiaGSM.RemoveCall(NokiaGSM.CallHistory[positionMaxDurationCall]); Console.Write("The total price of your {0} calls without the longest one is: ", NokiaGSM.CallHistory.Count); Console.WriteLine(NokiaGSM.CalculatePrice(0.37m)); NokiaGSM.ClearHistory(NokiaGSM.CallHistory); Console.Write("After clearing the history, there are {0} calls.", NokiaGSM.CallHistory.Count); Console.WriteLine(); }
static void Main(string[] args) { GSM phone = new GSM("S3", "Samsung", 1000, "Pesho", new Battery("T1", 33, 34, BatteryType.NiCd), new Display()); phone.AddCall(new Call(DateTime.Now, "0521512512", new TimeSpan(1, 30, 20))); phone.AddCall(new Call(DateTime.Now, "0521512512", new TimeSpan(3, 30, 20))); phone.AddCall(new Call(DateTime.Now, "0521512512", new TimeSpan(3, 30, 30))); TimeSpan longestDuration = phone.CallHistory[0].Duration; int index = 0; for (int i = 1; i < phone.CallHistory.Count; i++) { if (longestDuration < phone.CallHistory[i].Duration) { longestDuration = phone.CallHistory[i].Duration; index = i; } } phone.DeleteCall(index); PrintCallHistory(phone); }
static void Main() { // just some sample tests GSM tel = new GSM("Nokia", "gosho tupoto", owner: "Pesho"); tel.AddCall("0885032502", new DateTime(2003, 2, 1), new TimeSpan(0, 10, 15)); tel.AddCall("0883456782", new DateTime(2003, 2, 1), new TimeSpan(0, 20, 15)); tel.AddCall("+359885032548", new DateTime(2003, 2, 1), new TimeSpan(0, 10, 15)); tel.AddCall("+359885032576", new DateTime(2003, 2, 1), new TimeSpan(0, 15, 15)); Console.WriteLine(tel.GetCost(0.37)); tel.RemoveCall(); tel.PrintHistory(); Console.WriteLine(tel.GetCost(0.37)); tel.ClearHistory(); tel.PrintHistory(); Console.WriteLine(tel + "\n\n\n"); // IPhone test Console.WriteLine(GSM.IPhone4S); }
static void Main(string[] args) { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; GSM NokiaGSM = new GSM("Nokia", "NK", 180, "Gogo", new Battery("825L", 123, 100, BatteryType.LiIon), new Display(15, 1024)); NokiaGSM.AddCall(new Call(DateTime.Now, "088888888", 156)); NokiaGSM.AddCall(new Call(DateTime.Now.AddDays(3), "0888888899", 12)); NokiaGSM.AddCall(new Call(DateTime.Now.AddHours(1), "0888888344", 100)); NokiaGSM.AddCall(new Call(DateTime.Now.AddHours(56), "088883443", 1500)); decimal maxDuration = NokiaGSM.CallHistory[0].DurationInSeconds; int positionMaxDurationCall = 0; for (int i = 0; i < NokiaGSM.CallHistory.Count; i++) { Console.WriteLine("{0} call {1}",i+1, NokiaGSM.CallHistory[i]); Console.WriteLine(); if (NokiaGSM.CallHistory[i].DurationInSeconds>maxDuration) { maxDuration = NokiaGSM.CallHistory[i].DurationInSeconds; positionMaxDurationCall = i; } } Console.WriteLine(new string('-', 50)); Console.Write("The total price of your {0} calls is: ", NokiaGSM.CallHistory.Count); Console.WriteLine(NokiaGSM.CalculatePriceAllCalls(NokiaGSM.CallHistory, 0.37m)); NokiaGSM.RemoveCall(NokiaGSM.CallHistory[positionMaxDurationCall]); Console.Write("The total price of your {0} calls without the longest one is: ", NokiaGSM.CallHistory.Count); Console.WriteLine(NokiaGSM.CalculatePriceAllCalls(NokiaGSM.CallHistory, 0.37m)); NokiaGSM.ClearHistory(NokiaGSM.CallHistory); Console.Write("After clearing the history, there are {0} calls.", NokiaGSM.CallHistory.Count); Console.WriteLine(); }
static void Main() { //GSMTest Display the information about the GSMs in the array. GSM[] myGSMs = new GSM[5]; GSM phone; for (int i = 0; i < myGSMs.Length; i++) { phone = new GSM("model "+i,"manufact"); myGSMs[i]=phone; Console.WriteLine(myGSMs[i].ToString()); } //Display the information about the static property IPhone4S GSM.iPhone4s.ToString(); //Add few calls. phone = new GSM("jhgfhjg540", "manufact"); Random rand = new Random(); int phoneForDelete=0; for (int i = 0; i < 5; i++) { phone.AddCall(DateTime.Now, rand.Next(100000, 9999999).ToString(), rand.Next(1, 250)); if (i==2) { phoneForDelete=rand.Next(100000, 9999999); phone.AddCall(DateTime.Now, phoneForDelete.ToString(), rand.Next(1, 250)); i++; } } //Display the information about the calls. phone.DisplayCallHistory(); //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history. Console.WriteLine("Price: "+phone.CalcPrice(0.37)); //Remove the longest call from the history and calculate the total price again. phone.DeleteCall(phoneForDelete.ToString()); phone.DisplayCallHistory(); //Finally clear the call history and print it phone.ClearHistory(); phone.DisplayCallHistory(); }