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() { 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)); }
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); } }
static void Main(string[] args) { GSM gsm1 = new GSM("Nokia", "Nokia Corp"); GSM gsm2 = new GSM("Apple", "Apple Inc."); gsm1.Price = 1300; gsm1.Battery.HoursIdle = 120; gsm1.Battery.HoursTalk = 12; gsm1.TypeOfBattery = Battery.BatteryType.NiCd; gsm1.Battery.Model = "China"; gsm1.Display.NumberOfColors = 16; gsm1.Display.Size = 4.5; gsm1.AddCallToHistory("26.2.2013", "12:00", 0887698631, 123); gsm1.AddCallToHistory("27.2.2013", "12:00", 0887698631, 123); gsm1.AddCallToHistory("28.2.2013", "12:00", 0887698631, 123); gsm1.Owner = "Pencho"; Console.WriteLine(gsm1); Console.WriteLine(gsm1.CallPrice(0.45m)); //GSM gsm2 = GSM.IPhone4S; //Console.WriteLine(gsm2); //GSMTest gsm3 = new GSMTest(5); //foreach (var item in gsm3) //{ // Console.WriteLine(item); //} }
static void Main() { GSM gsm = new GSM("Galaxy S3", "Samsung"); gsm.AddCall(846022, 150); gsm.AddCall(35956, 132); Console.WriteLine(gsm.CallsPrice(0.37m)); }
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() { 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); }
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); }
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()); }
static void Main(string[] args) { GSM testGSM = new GSM("1000", "Nokia"); testGSM = FillGSMCalls(testGSM); Console.WriteLine(new String('*', 20)); Console.WriteLine("List all calls:"); Console.WriteLine(testGSM.ListAllCalls()); Console.WriteLine(new String('*', 20)); Console.WriteLine("The price of all calls is: {0}", testGSM.CalcAllCallPrice((decimal)0.37)); int indexMaxCall = 0; for (int i = 1; i < testGSM.CallHistory.Count; i++) { if (testGSM.CallHistory[indexMaxCall].Duration < testGSM.CallHistory[i].Duration) { indexMaxCall = i; } } testGSM.RemoveCall(indexMaxCall); Console.WriteLine(new String('*', 20)); Console.WriteLine("The new price of all calls is: {0}", testGSM.CalcAllCallPrice((decimal)0.37)); testGSM.RemoveAllCalls(); Console.WriteLine(new String('*', 20)); Console.WriteLine("List all calls:"); Console.WriteLine(testGSM.ListAllCalls()); }
static void Main() { GSM gsm = new GSM("nokia", "nokiaman"); GSM gsm1 = new GSM("nokia", "nok", 9.5m); Battery bat = new Battery("monbat", 500, 100, BatteryType.NiMH); Display dis = new Display(null, 256); GSM gsm2 = new GSM("erik", "erik", bat); GSM gsm3 = new GSM("koko", "ka", dis); Console.WriteLine(gsm.ToString()); Console.WriteLine("-----"); Console.WriteLine(gsm1.ToString()); Console.WriteLine("-----"); Console.WriteLine(gsm2.ToString()); Console.WriteLine("-----"); Console.WriteLine(gsm3.ToString()); Console.WriteLine("---------------------------"); GSM p = GSM.IPhone4S; p.Owner = "pesho"; p.Battery = bat; Console.WriteLine(p.ToString()); GSMCallHistoryTest.Test(); }
public static void TestPrint() { testGSMs[0] = new GSM("Desire S", "HTC", bat: new Battery("HTCBattery", hoursIdle: 100M), disp: new Display(4M)); testGSMs[1] = new GSM("Desire S", "HTC", bat: new Battery("HTCBattery", hoursIdle: 100M), disp: new Display(4M)); testGSMs[2] = GSM.IPhone4S; foreach (GSM gsm in testGSMs) { Console.WriteLine(gsm); } testGSMs[0].AddCall("8427153", 60); testGSMs[0].AddCall("8435153", 60); testGSMs[0].AddCall("8437153", 70); testGSMs[0].ViewCalls(); Console.WriteLine("Total price = {0:C}", testGSMs[0].CalculatePrice(0.30M)); testGSMs[0].RemoveCall("8437153"); testGSMs[0].ViewCalls(); Console.WriteLine("Total price = {0:C}", testGSMs[0].CalculatePrice(0.30M)); testGSMs[0].ClearHistory(); testGSMs[0].ViewCalls(); Console.WriteLine("Total price = {0:C}", testGSMs[0].CalculatePrice(0.30M)); }
/// <summary> /// Called when graphics resources need to be unloaded. /// </summary> public override void UnloadContent() { GSM.UnloadContent(); Gui.GUI.Dispose(); ResourceManager.ClearAssets(); }
public async Task <IActionResult> Edit(int id, [Bind("id_gsm,numero,equipamento")] GSM gSM) { if (id != gSM.id_gsm) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(gSM); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GSMExists(gSM.id_gsm)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(gSM)); }
public void CreateFewGSMInstances() { instancesArray[0] = new GSM("3100", "Nokia", 120, "John Doe"); instancesArray[1] = new GSM("W175", "Motorola", 10); instancesArray[2] = new GSM("5", "IPhone", "Johnny Retard"); instancesArray[3] = new GSM("50", "IPhone"); }
public void CreateFewGSMInstances() { instancesArray[0] = new GSM("3100", "Nokia", 120, "John Doe"); instancesArray[1] = new GSM("W175", "Motorola", 10); instancesArray[2] = new GSM("5", "IPhone", "Johnny Retard"); instancesArray[3] = new GSM("50", "IPhone"); }
public static void Main() { GSM[] gsmArray = new GSM[3]; gsmArray[0] = new GSM("X10", "Sony Ericsson", 600, "Ceco", new Battery("BST-41", 425, 8, BatteryType.LiIon), new Display(4.0f, 16000000)); gsmArray[1] = new GSM("M2", "Sony", 800, "Pesho", new Battery("BST-127", 625, 12, BatteryType.LiPolymer), new Display(5.0f, 16000000)); gsmArray[2] = new GSM("Z3", "Sony", 1000, "Gosho", new Battery("BST-300", 825, 24, BatteryType.LiIon), new Display(6.0f, 16000000)); foreach (var gsm in gsmArray) { Console.WriteLine(gsm.ToString()); Console.WriteLine("------------------------------"); } Console.WriteLine(GSM.IPhone4S); Console.WriteLine(); ///Test GSMCallHistoryTest. Console.Write("Test the call hystory class? [yes/no]: "); if (Console.ReadLine() == "yes") { Console.Clear(); GSMCallHistoryTest.TestCallHistory(); } }
static void Main() { GSM TestGSM = new GSM("GALAXY S4", "Samsung", 1365, "Ivan", new Battery("Toshiba", 24, 12, BatteryType.LiIon), new Display(7, 256)); GSM[] arrayOfGSM = { TestGSM, GSM.IPhone4S }; foreach (var item in arrayOfGSM) { Console.WriteLine(item.ToString()); Console.WriteLine(); } TestGSM.AddCallsToHistory(new Call(DateTime.Now, "0834567822", 66)); TestGSM.AddCallsToHistory(new Call(DateTime.Now, "0888456378", 99)); TestGSM.AddCallsToHistory(new Call(DateTime.Now, "0899456578", 115)); TestGSM.DisplayCallHistory(); Console.WriteLine(); Console.WriteLine("Total price of calls is : {0:F3} leva ", TestGSM.TotalPriceOfCalls()); Console.WriteLine(); TestGSM.DeleteCallFromHistory(); Console.WriteLine(); TestGSM.DisplayCallHistory(); Console.WriteLine(); Console.WriteLine("Total price of calls is : {0:F3} leva ", TestGSM.TotalPriceOfCalls()); TestGSM.ClearCallHistory(); Console.WriteLine(); TestGSM.DisplayCallHistory(); }
static void Main(string[] args) { GSM[] phones = new GSM[] { new GSM("Glaxy S4", "Samsung", 899.99m, "Tsvetomir", new Battery("Samsung", BatteryType.LiIon, 8, 40), new Display(5.0f, 16000000)), new GSM("Glaxy S4", "Samsung", 599.99m, "Jack", new Battery("HTC", BatteryType.NiCd, 8, 40), new Display(5.0f, 16000000)), new GSM("Grand X", "ZTE", 199.99m, "John", new Battery("Samsung", BatteryType.NiMH, 8, 40), new Display(4.0f, 160000)) }; foreach (var gsm in phones) { Console.WriteLine(gsm.ToString()); Console.WriteLine(); } Console.WriteLine(GSM.Iphone4S.ToString()); Console.WriteLine(); GSM newGsm = new GSM("Glaxy S4", "Samsung", 899.99m, "Tsvetomir", new Battery("Samsung", BatteryType.LiIon, 8, 40), new Display(5.0f, 16000000)); newGsm.AddCallToHistory(new Call(DateTime.Now, "08899288329", 220)); newGsm.AddCallToHistory(new Call(DateTime.Now, "09921299218", 498)); decimal totalPrice = newGsm.CalculateTotalPriceOfCalls(3.47m); Console.WriteLine("Total price: {0}", totalPrice); }
public static void Test() { GSM[] phones = new GSM[] { new GSM("3310", "Nokia", 200m, "John", new Battery("123-23AFF", BatteryType.LiIon, 24, 3), new Display(4, 1)), new GSM("k700i", "Sony-Ericsson", 50m, "Me", new Battery("Ox-315F", BatteryType.Unknown, 48, 5), new Display(4, 65000)), new GSM("Lumnia", "Nokia"), new GSM("iPhone", "Apple", new Battery("aa-22", 100, 10), new Display(8, 2000000)), new GSM("M-35", "Siemens", 50m, "Radi predi 10 godini") }; foreach (var gsm in phones) { Console.WriteLine("========================="); Console.WriteLine(gsm); } Console.WriteLine("========================="); Console.WriteLine(GSM.IPhone4S); }
public static void TestRunner() { // Create a few instances of the GSM class List<GSM> mobilePhones = new List<GSM>(); // Mobile N.1 { mobilePhones.Add(new GSM("Asha 501", "Nokia", "GLOBUL", 599.99m, new Display(3, 1250000))); } // Mobile N.2 { GSM mobile = new GSM("Xperia ray", "Sony Ericsson"); mobile.Owner = "Vivacom"; mobile.Price = 250; mobile.Battery = new Battery(Battery.Type.NiMH); mobile.Battery.HoursTalk = 200; mobilePhones.Add(mobile); } // Display information about phones in array foreach (var phone in mobilePhones) Console.Write(phone); // Mobile N.3 // Display information about IPhone 4S Console.Write(GSM.Iphone4S); }
//test the call history functionality static void Main() { //Create a new mobile phone GSM mobile = new GSM("Xperia", "Sony", 670.99, "Kitty"); //Get information about created mobile phone mobile.ToString(); //Get information about static field iPhone GSM.IPhone4S.ToString(); //Add calls and print mobile.AddCalls(DateTime.Now, "+359 885 440 340", 1); mobile.AddCalls(DateTime.Now, "+359 886 789 451", 94); mobile.PrintCalls(); //Delete call and print mobile.DeleteCalls(2); mobile.PrintCalls(); //Calculate total price mobile.CalculateFinalPrice(0.35); //Clear calls and print mobile.ClearCalls(); }
public void TestMethod2() { GSM testGSM = GSMCallHistoryTest.FillGSMCalls(new GSM("1000", "Nokia")); string testResultString = ""; //Check all calls display testResultString = String.Format("1 : To 0888 888 888 at {0} for 40 seconds\r\n2 : To 0888 888 888 at {0} for 190 seconds\r\n3 : To 0888 888 888 at {0} for 130 seconds\r\n", DateTime.Now); Assert.AreEqual(testResultString, testGSM.ListAllCalls()); //Check all calls price Assert.AreEqual((decimal)2.96, testGSM.CalcAllCallPrice((decimal)0.37)); //Check all calls price withoud the longest call int indexMaxCall = 0; for (int i = 1; i < testGSM.CallHistory.Count; i++) { if (testGSM.CallHistory[indexMaxCall].Duration < testGSM.CallHistory[i].Duration) { indexMaxCall = i; } } testGSM.RemoveCall(indexMaxCall); Assert.AreEqual((decimal)1.48, testGSM.CalcAllCallPrice((decimal)0.37)); //Check all calls list when empty testGSM.RemoveAllCalls(); Assert.AreEqual("", testGSM.ListAllCalls()); }
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); }
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); } }
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(); }
public void TestHistoryDisplay() { GSM phone = new GSM("lala", "sumsAng", "batman", 10000.99); DateTime date = new DateTime(); DateTime.TryParse("2.2.2013 14:34", out date); phone.MakeCall(date, "0899999999", 3.44); DateTime.TryParse("6.2.2013 19:34:11", out date); phone.MakeCall(date, "0899999999", 3.44); DateTime.TryParse("11.2.2013 12:32:59", out date); phone.MakeCall(date, "0889666999", 9.44); DateTime.TryParse("12.2.2013 15:30:00", out date); phone.MakeCall(date, "0009666999", 9.44); string expected = @"12-Feb-13 15:30:00 11-Feb-13 12:32:59 06-Feb-13 19:34:11 02-Feb-13 14:34:00 "; StringBuilder sb = new StringBuilder(); foreach (var item in phone.GetCallsByDate()) { sb.AppendLine(item.ToString()); } Assert.AreEqual(expected, sb.ToString()); }
public void HistoryTest() { Console.WriteLine(new string('-', 50)); Console.WriteLine(" Calls history"); Console.WriteLine(new string('-', 50)); Console.WriteLine(); GSM phone = new GSM(); phone.AddHistory(DateTime.Now, "0891234567", 10); phone.AddHistory(DateTime.Now, "0883456789", 47.99); phone.AddHistory(DateTime.Now, "0872345678", 89.01); phone.PrintCalls(); Console.WriteLine(); Console.WriteLine("Assuming the price per minute is 0.37! Calculate the total price of the calls:"); Console.WriteLine(new string('-', 77)); phone.CalculateTotalPrice(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Delete longest call from the history and calculate the total price again:"); Console.WriteLine(new string('-', 74)); phone.DeleteHistory(89.01); phone.CalculateTotalPrice(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(new string('-', 50)); Console.WriteLine(" Calls history after delete"); Console.WriteLine(new string('-', 50)); Console.WriteLine(); phone.ClearHistory(); phone.CalculateTotalPrice(); }
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[] gsmArr = new GSM[3]; string[] gsmModelArr = { "N90","5800","N70"}; string[] gsmManufacturerArr = { "Nokia","HTC","Samsung"}; decimal[] gsmPriceArr = { 1000m, 200.34m, 2000.3434m}; string[] gsmOwnerArr = { "IBot","IDummy","IWorm"}; for (int i = 0; i < gsmArr.Length; i++) { gsmArr[i] = new GSM(gsmModelArr[i], gsmManufacturerArr[i], gsmPriceArr[i], gsmOwnerArr[i]); Console.WriteLine("Override ToString(): "); Console.WriteLine(gsmArr[i].ToString()); Console.WriteLine(gsmModelArr[i]); Console.WriteLine(gsmManufacturerArr[i]); Console.WriteLine(gsmPriceArr[i]); Console.WriteLine(gsmOwnerArr[i]); } GSM iphone = new GSM(null,null); iphone.iPhone4s.PhoneManufacturer = "Apple Corp."; iphone.iPhone4s.PhoneModel = "iPhone 4 S"; Console.WriteLine(iphone.iPhone4s.PhoneManufacturer); Console.WriteLine(iphone.iPhone4s.PhoneModel); }
static void Main() { Console.WriteLine("GSM instances test"); Console.WriteLine(new string('-', 30)); //creates array with GSM instances var gsms = new GSM[] { new GSM("Galaxy S3","Samsung"), new GSM("G2 Mini", "LG", 190, new Battery("2440 mAh", 700, 12, Battery.Type.LiIon), new Display(540, 960, 16000000), "Martin"), new GSM("Nexus 6", "Motorola", new Display(1440, 2560)), new GSM("One M9", "HTC", 500, new Battery("Non-removable 2840 mAh", 391, 25), new Display(1080, 1920, 160000000)) }; //displays the information about the GSMs in the array foreach (var gsm in gsms) { Console.WriteLine(gsm.ToString()); } //displays the information about the static property IPhone4S Console.WriteLine("Information about iPhone 4S: "); Console.WriteLine(new string('-', 30)); Console.WriteLine(GSM.IPhone4S); //tests calls GSMCallHistoryTest.CallHistoryTest(); }
static void Main(string[] args) { GSM phone = new GSM("lala", "sumsAng", "batman", 10000.99); phone.MakeCall(DateTime.Now, "0899999999", 3.44); phone.MakeCall(DateTime.Now.AddHours(3), "0899999999", 3.44); phone.MakeCall(DateTime.Now.AddDays(99), "0889666999", 9.44); phone.MakeCall(DateTime.Now.AddDays(5).AddHours(10), "0009666999", 9.44); Console.WriteLine("Calls ordered by date: "); foreach (DateTime timeOfCall in phone.GetCallsByDate()) { Console.WriteLine(timeOfCall.ToString()); } phone.DeleteCall(2); Console.WriteLine("New calls: "); foreach (DateTime timeOfCall in phone.GetCallsByDate()) { Console.WriteLine(timeOfCall.ToString()); } phone.ClearCallHistory(); Console.WriteLine("\nNothing will show, because history is deleted: "); foreach (DateTime timeOfCall in phone.GetCallsByDate()) { Console.WriteLine(timeOfCall.ToString()); } }
static void Main() { GSM[] mobilePhones = new GSM[3]; GSM nokia = new GSM("3310", "Nokia"); nokia.AddHistory(DateTime.Now, 0998080907, 1.08); nokia.AddHistory(DateTime.Now, 0998080907, 2132331.08); nokia.DeleteHistory(1); Battery sonyBattery5511 = new Battery("77ds7", 220, 10, BatteryType.NiMH); Display sonyDisplay5511 = new Display(23, 128); GSM sony = new GSM("5511", "Sony", 100.77m, "Pesho", sonyBattery5511, sonyDisplay5511); GSM samsung = new GSM("4433", "samsung", 50.22m, "Gosho"); mobilePhones[0] = nokia; mobilePhones[1] = sony; mobilePhones[2] = samsung; //Console.WriteLine(nokia.CalcPriceHistory(2.2m)); for (int i = 0; i < mobilePhones.Length; i++) { Console.WriteLine(mobilePhones[i]); } }
static void Main(string[] args) { GSM[] gsmArray = new GSM[3]; Battery myBattery = new Battery("Nokia", 50,50, BatteryType.LiIon); Display myDisplay = new Display(10, 1000000); GSM firstGsm = new GSM("N8", "Nokia", 500, "Me", myBattery, myDisplay); gsmArray[0] = firstGsm; myBattery = new Battery("Samsung", 60, 60, BatteryType.NiCd); myDisplay = new Display(12, 1200000); GSM secondGsm = new GSM("Galaxy", "Samsung", 700, "Me", myBattery, myDisplay); gsmArray[1] = secondGsm; myBattery = new Battery("HTC", 40, 40, BatteryType.NiMH); myDisplay = new Display(8, 800000); GSM thirdGsm = new GSM("K8", "HTC", 450, "Me", myBattery, myDisplay); gsmArray[2] = thirdGsm; foreach (var item in gsmArray) { Console.WriteLine(item); Console.WriteLine(); } Console.WriteLine(GSM.IPhone4S); GSMCallHistoryTest.Test(); }
static void Main(string[] args) { GSM gsm1 = new GSM("Apple", "Apple Inc."); gsm1.PhonePrice = 1300; gsm1.Battery.HoursIdle = 120; gsm1.Battery.HoursTalk = 12; gsm1.Battery.TypeOfBattery = Battery.BatteryType.LiIon; gsm1.Battery.Model = "China"; gsm1.Display.NumberOfColors = 16; gsm1.Display.Size = 4.5; gsm1.Owner = "Pencho"; Console.WriteLine(gsm1); //todo: asdf GsmCallHistoryTest testPhone = new GsmCallHistoryTest(); testPhone.AddSomeCalls(5); Console.WriteLine(testPhone); testPhone.PricePerMinute = 0.37m; Console.WriteLine("Price per minute: {0}", testPhone.PricePerMinute + " лв."); Console.WriteLine("Price for all phone calls in history: {0}", Math.Round(testPhone.CalculatePrice(), 3) + " лв."); testPhone.DeleteLongestCall(); Console.WriteLine(testPhone); Console.WriteLine("Price for all phone calls in history: {0}", Math.Round(testPhone.CalculatePrice(), 3) + " лв."); testPhone.ClearHistory(); Console.WriteLine("History is deleted !"); Console.WriteLine(testPhone); }
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); } }
static void Main() { // Generate some test batteries and displays Display premiumDisplay = new Display(4.5, Display.ColorDepth._32Bit); Display mediocreDisplay = new Display(3.5, Display.ColorDepth._16Bit); Display poorDisplay = new Display(2.5, Display.ColorDepth._8bit); Battery premiumBattery = new Battery("Sanyo-SN532e", 120, 20, Battery.Type.LiPol); Battery mediocreBattery = new Battery("Shanzungmang-2341", 80, 15, Battery.Type.LiIon); Battery poorBattery = new Battery("Mistucura-1224fe", 40, 5, Battery.Type.NiMH); // initilize gsms in the array GSM[] gsmArray = new GSM[4]; gsmArray[0] = new GSM("One", "HTC", 200, "Kiro", premiumDisplay, premiumBattery); gsmArray[1] = new GSM("Blade", "Zte"); gsmArray[2] = new GSM("Galaxy S4", "Samsung", 1000, "Misho", premiumDisplay, mediocreBattery); gsmArray[3] = new GSM("Ascend G600", "Huawei", 600, "Mtel", premiumDisplay, new Battery("Toshiba-tbsae", 380, 6, Battery.Type.LiPol)); // print the gsms foreach (GSM phone in gsmArray) { Console.WriteLine(phone); } // print the static property Iphone4S Console.WriteLine(GSM.Iphone4S); // test GsmCallHistory GSMCallHistoryTest.Test(); }
public void GSMWithAllDetails() { Display someDisplay = new Display(45000,new DisplaySize(1024,768)); Battery superBattery = new Battery("kon",1000,1000,BatteryType.NiMH); GSM megaPhone = new GSM("Super Phone", "Krypton", 750,someDisplay,superBattery); Console.WriteLine(megaPhone); }
static void CallsInfo(GSM gsmTwo) { foreach (var call in gsmTwo.CallHistory) { Console.WriteLine(call.ToString()); } }
static void Main() { Console.OutputEncoding = System.Text.Encoding.Unicode; GSM myPhone = new GSM("3310", "Nokia", 1000M, "Ivan", new Display(1740, 33480, 160000000), new Battery("PK15", 50000, 2000, BatteryType.LiPol)); myPhone.AddCall("08999333888", DateTime.Now, 200); myPhone.AddCall("08999333888", DateTime.Now, 300); myPhone.AddCall("08888333888", DateTime.Now, 400); myPhone.AddCall("08888333888", DateTime.Now, 500); myPhone.AddCall("09999999999", DateTime.Now, 1); myPhone.AddCall("08888555555", DateTime.Now, 200); myPhone.AddCall("08888555555", DateTime.Now, 300); myPhone.AddCall("08888555555", DateTime.Now, 400); myPhone.AddCall("08888555555", DateTime.Now, 10101); Console.WriteLine(myPhone.ShowCallHistory()); Console.WriteLine("Total call price: {0:C2}", myPhone.TotalCallPrice(0.37M)); myPhone.DeleteLongestCall(); myPhone.DeleteShortestCall(); myPhone.DeleteCall(3); Console.WriteLine(new string('*', 50)); Console.WriteLine(myPhone.ShowCallHistory()); myPhone.ClearCallHistory(); Console.WriteLine(new string('*', 50)); Console.WriteLine(myPhone.ShowCallHistory()); }
static void Main() { try { GSM[] phones = new GSM[3]; GSM.iPhone4S = new GSM("4S", "iPhone", 999.99, "Batman", new Battery("ZHDS384", 200, 8, BatteryType.LiIon), new Display(11, 160000000)); phones[0] = new GSM("E51", "Nokia", 100.00, "John Johnson", new Battery("A1396", 300, 10, BatteryType.LiIon), new Display(10, 256000)); phones[1] = new GSM("Windows Phone 8X", "HTC", 700.00); phones[1].Owner = "Jack"; phones[1].Battery = new Battery("S38FS2", 250, 15, BatteryType.LiIon); phones[1].Display = new Display(8, 1600000); phones[2] = new GSM("i8750 Ativ S", "Samsung", 999.00, "Ivan Ivanov", new Battery("X38U32", 290, 11, BatteryType.NiMH), new Display(7, 200000)); foreach (GSM phone in phones) Console.WriteLine(phone.ToString() + "\n********************"); Console.WriteLine(GSM.iPhone4S.ToString()); } catch (ArgumentException e) { Console.WriteLine(e.Message); } }
static void Main(string[] args) { GSM informationForGsm = new GSM(); Console.WriteLine("Enter name on owner:"); informationForGsm.Owner = Console.ReadLine(); Console.WriteLine("Enter name on model:"); informationForGsm.Model = Console.ReadLine(); Console.WriteLine("Enter name on price:"); informationForGsm.Price = decimal.Parse(Console.ReadLine()); Console.WriteLine("Enter name on manufacturer:"); informationForGsm.Manufacturer = Console.ReadLine(); Console.WriteLine("Name model of Batery:"); informationForGsm.Battery.BatteryModel = Console.ReadLine(); Console.WriteLine("How time is batery limit?"); informationForGsm.Battery.HoursIdle = int.Parse(Console.ReadLine()); Console.WriteLine("Size of display:"); informationForGsm.Display.Size = Console.ReadLine(); Console.WriteLine("Number of coclor on display:"); informationForGsm.Display.NumberOfColors = Console.ReadLine(); Console.WriteLine("Owner:{0},\nModer:{1},\nPrice:{2},\nManufacturer:{3},\nBatery:{4},\nDisplay:{5},\nSize of display:{6}" , informationForGsm.Owner, informationForGsm.Model, informationForGsm.Price, informationForGsm.Manufacturer, informationForGsm.Battery.BatteryModel, informationForGsm.Battery.HoursIdle, informationForGsm.Display.NumberOfColors, informationForGsm.Display.Size); }
static void Main() { DateTime date1 = new DateTime(2013, 5, 24, 11, 11, 30); DateTime date2 = new DateTime(2013, 5, 24, 15, 23, 2); DateTime date3 = new DateTime(2013, 5, 31, 9, 00, 00); DateTime date4 = new DateTime(2013, 5, 31, 18, 12, 20); Call call1 = new Call(date1, "0888313233", 850); Call call2 = new Call(date2, "0888909090", 95); Call call3 = new Call(date3, "0889556677", 213); Call call4 = new Call(date4, "0888313233", 37); Battery battery = new Battery("PX8", BatteryType.LiIon, 300, 8); Display display = new Display(4, 16000000); GSM gsm = new GSM("I900", "Samsung", 500, "Me", battery, display); gsm.AddCalls(call1); gsm.AddCalls(call2); gsm.AddCalls(call3); gsm.AddCalls(call4); foreach (var call in gsm.CallHistory) { Console.WriteLine(call); } Console.WriteLine("Total amount to pay: {0:C}", gsm.TotalCallsPrice); gsm.DeleteCalls(call1); Console.WriteLine("Total amount to pay: {0:C}", gsm.TotalCallsPrice); gsm.ClearHistory(); Console.WriteLine("Total amount to pay: {0:C}", gsm.TotalCallsPrice); }
public static void TestGSM() { GSM[] gsms = new GSM[4]; GSM gsm = new GSM("Samsung Galaxy S Duos S7582", "Samsung", 100M, new Battery(BatteryTypes.LiIon, 310, 8), new Display(4, 16 * 1024)); gsms[0] = gsm; gsm = new GSM("Samsung E1200", "Samsung", 15M, new Battery(BatteryTypes.LiIon, 720, 7), new Display(1.52, 65)); gsms[1] = gsm; gsm = new GSM("Samsung E2202", "Samsung", 35M); gsms[2] = gsm; gsm = new GSM("ALCATEL ONETOUCH 1046", "Alcatel"); gsms[3] = gsm; for (int i = 0; i < gsms.Length; i++) { Console.WriteLine(gsms[i]); Console.WriteLine(); } Console.WriteLine(GSM.IPhone4S); }
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() { Display testDisplay = new Display(14, 16.5f); Battery testBattery = new Battery("test"); GSM myPhone = new GSM("test", "test", "Owner",1234, testBattery, testDisplay); Console.WriteLine(myPhone.display.Size); }
static void Main() { GSM gsm = new GSM("nokia", "nokiaman"); GSM gsm1 = new GSM("nokia", "nok", 9.5m); Battery bat = new Battery("monbat", 500, 100, BatteryType.NiMH); Display dis = new Display(null, 256); GSM gsm2 = new GSM("erik", "erik", bat); GSM gsm3 = new GSM("koko", "ka", dis); Console.WriteLine(gsm.ToString()); Console.WriteLine("-----"); Console.WriteLine(gsm1.ToString()); Console.WriteLine("-----"); Console.WriteLine(gsm2.ToString()); Console.WriteLine("-----"); Console.WriteLine(gsm3.ToString()); Console.WriteLine("---------------------------"); GSM p = GSM.IPhone4S; p.Owner = "pesho"; p.Battery = bat; Console.WriteLine(p.ToString()); GSMCallHistoryTest.Test(); }
public static void Main(string[] args) { GSM gsmGosho = new GSM("0898204521"); BankAccount bankAccountGosho = new BankAccount(); GSM gsmIvan = new GSM("0898704382"); BankAccount bankAccountIvan = new BankAccount(); Person gosho = new Person("Georgi Ivanov", bankAccountGosho, gsmGosho); Person ivan = new Person("Ivan Georgiev", bankAccountIvan, gsmIvan); //Starting money gosho.Account.Balance = 200.00m; ivan.Account.Balance = 9.00m; //Creating array of Person and give clients to the company Person[] clients = new Person[2]; clients[0] = gosho; clients[1] = ivan; MobileCompany mobileCompany = new MobileCompany(clients); mobileCompany.MontlyCharge(9.99m); }
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); } }
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); } }
private static void Main() { // Generate some test batteries and displays var premiumDisplay = new Display(4.5, Display.ColorDepth._32Bit); var mediocreDisplay = new Display(3.5, Display.ColorDepth._16Bit); var poorDisplay = new Display(2.5, Display.ColorDepth._8bit); var premiumBattery = new Battery("Sanyo-SN532e", 120, 20, Battery.Type.LiPol); var mediocreBattery = new Battery("Shanzungmang-2341", 80, 15, Battery.Type.LiIon); var poorBattery = new Battery("Mistucura-1224fe", 40, 5, Battery.Type.NiMH); // initilize gsms in the array var gsmArray = new GSM[4]; gsmArray[0] = new GSM("One", "HTC", "Kiro", premiumDisplay, premiumBattery, 200); gsmArray[1] = new GSM("Blade", "Zte"); gsmArray[2] = new GSM("Galaxy S4", "Samsung", "Misho", premiumDisplay, mediocreBattery, 1000); gsmArray[3] = new GSM("Ascend G600", "Huawei", "Mtel", premiumDisplay, new Battery("Toshiba-tbsae", 380, 6, Battery.Type.LiPol), 600); // print the gsms foreach (var phone in gsmArray) { Console.WriteLine(phone); } // print the static property Iphone4S Console.WriteLine(GSM.Iphone4S); // test GsmCallHistory GSMCallHistoryTest.Test(); }
public static void TestRunner() { // Create a few instances of the GSM class List <GSM> mobilePhones = new List <GSM>(); // Mobile N.1 { mobilePhones.Add(new GSM("Asha 501", "Nokia", "GLOBUL", 599.99m, new Display(3, 1250000))); } // Mobile N.2 { GSM mobile = new GSM("Xperia ray", "Sony Ericsson"); mobile.Owner = "Vivacom"; mobile.Price = 250; mobile.Battery = new Battery(Battery.Type.NiMH); mobile.Battery.HoursTalk = 200; mobilePhones.Add(mobile); } // Display information about phones in array foreach (var phone in mobilePhones) { Console.Write(phone); } // Mobile N.3 // Display information about IPhone 4S Console.Write(GSM.Iphone4S); }
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(string[] args) { GSM gsm1 = new GSM("Nokia", "Nokia Corp"); gsm1.Price = 1300; gsm1.Battery.HoursIdle = 120; gsm1.Battery.HoursTalk = 12; gsm1.TypeOfBattery = Battery.BatteryType.NiCd; gsm1.Battery.Model = "China"; gsm1.Display.NumberOfColors = 16; gsm1.Display.Size = 4.5; gsm1.Owner = "Pencho"; Console.WriteLine(gsm1); GSM gsm2 = GSM.IPhone4S; Console.WriteLine(gsm2); GSMTest gsm3 = new GSMTest(5); foreach (var item in gsm3) { Console.WriteLine(item); } }
static void Main(string[] args) { GSM gsm1 = new GSM("Nokia", "Nokia Corp"); gsm1.Price = 1300; gsm1.Battery.HoursIdle = 120; gsm1.Battery.HoursTalk = 12; gsm1.TypeOfBattery = Battery.BatteryType.NiCd; gsm1.Battery.Model = "China"; gsm1.Display.NumberOfColors = 16; gsm1.Display.Size = 4.5; gsm1.Owner = "Pencho"; Console.WriteLine(gsm1); GSM gsm2 = GSM.IPhone4S; Console.WriteLine(gsm2); GSMTest gsm3 = new GSMTest(5); foreach (var item in gsm3) { Console.WriteLine(item); } }
public static void TestGSM() { StringBuilder sb = new StringBuilder(); Manufacturer htc = new Manufacturer("HTC", "USA"); Manufacturer lg = new Manufacturer("LG", "USA"); Manufacturer nokia = new Manufacturer("Nokia", "USA"); GSM[] gsms = new GSM[3]; GSM evo3D = new GSM("Evo 3D", htc, 500, new Battery(BatteryType.LiIon, 40, 30), new Display(5, 1500)); GSM nexus = new GSM("Nexus 5", lg, 300, new Battery(BatteryType.LiIon, 50, 20), new Display(6, 10000)); GSM lumia = new GSM("Lumia", nokia, 250, new Battery(), new Display()); gsms[0] = evo3D; gsms[1] = nexus; gsms[2] = lumia; sb.AppendLine("GSM tests:") .AppendLine(); foreach (var gsm in gsms) { sb.AppendLine(gsm.ToString()); sb.AppendLine(); } sb.AppendLine(GSM.IPhone4S.ToString()); Console.WriteLine(sb.ToString()); }
//initialize the static iPhone GSM static GSM() { DisplaySize iPhoneDisplaySize = new DisplaySize(1136, 640); Display iPhoneDisplay = new Display(32000, iPhoneDisplaySize); Battery iPhoneBattery = new Battery("Samsung", 24, 24, BatteryType.LiIon); iPhone4S = new GSM("4S", "Apple", 1000000, iPhoneDisplay, iPhoneBattery); }
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(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)); }