static void Main(string[] args) { GSM phone1 = new GSM("ZTE N281", "ZTE (HK) Ltd", 88.9, "Gergi", new Battery("Hardmodel#", 8, 4, BattertType.Li_Lon), new Display(4.1, 32000)); GSM phone2 = new GSM("Samsung S4", "Samsung corp.", 128.9, "Ivan", new Battery("newLine", 6, 3, BattertType.NiMH), new Display(4.9, 64000)); GSM phone3 = new GSM("Nokia N95", "Microsoft Mobile", 100, "Sracimir", new Battery("newLine", 7, 3, BattertType.Li_Lon), new Display(4, 128000)); GSM phone4 = new GSM("Lenovo S850", "Lenovo Co", 155.5, "Petkan", new Battery("LenBatMod", 5, 2, BattertType.Li_Lon), new Display(4.1, 256000)); GSM phone5 = new GSM("HTC One M8", "HTC", 654.9, "The King", new Battery("Spectum", 18, 2, BattertType.NiCD), new Display(5, 512000)); GSM phone6 = new GSM("Motorola Z2", "Motorola corp.", 16.6, "Kloshar", new Battery("SOmemodel", 2, 9, BattertType.Unknown), new Display(1.5, 1024000)); GSM phone7 = new GSM("Nokia N5", "Microsoft Mobile", 58.9, "Someone", new Battery("Unknown", 8, 3, BattertType.Li_Lon), new Display(3.9, 2048000)); GSM phone8 = new GSM("Prestigio", "Prestigio Europe", 16.5, "Operator", new Battery("Sd", 8, 5, BattertType.NiCD), new Display(4.1, 4096000)); GSM phone9 = new GSM("Cat", "Soft Company", 119.2, "Marzelinio", new Battery("Unknown", 5, 2, BattertType.Li_Lon), new Display(3, 8216000)); GSM[] telefoni = new GSM[] { phone1, phone2, phone3, phone4, phone5, phone6, phone7, phone8, phone9 }; foreach (var item in telefoni) { Console.WriteLine(item); Console.WriteLine(); } Console.WriteLine(GSM.iPhone4S); // GSM.iPhone4S.Manufacturer = " apifjoas"; ha yes Console.WriteLine(); Console.WriteLine("Press any key to continie with testing calls"); Console.ReadLine(); Console.WriteLine("Testing Calls"); GSMCallHistoryTest(); }
public static void GSMTestMethod() { //GSM[] phoneDevices = new GSM[3]; //string[] models = { "Samsung", "LG", "HTC" }; //string[] manufacturers = { "UK", "China", "Japan" }; //decimal[] prices = { 1200, 1100, 750 }; //string[] owners = { "Pesho", "Gosho", "Dragan" }; //Battery[] batteries = //{ //new Battery(), new Battery("Better", 250, 25, BatteryTypes.LiIon), //new Battery("Bad", 50, 5, BatteryTypes.NiCd), new Battery("TestModel", 300, 30, BatteryTypes.NiMH) //}; GSM test1 = new GSM("Samsung", "Samsung C&T Corporation", 140000, "HappyOwner", new Battery("Standard", 100.0, 10.0, BatteryTypes.LiIon), new Display(), new List<Call>()); GSM test2 = new GSM("Nokia", "Microsoft Corporation"); GSM test3 = new GSM("Sony", "Sony Corporation", 100, "Me&Myself", new Battery(), new Display(), new List<Call>()); GSM[] allPhones = { test1, test2, test3 }; foreach (var gsm in allPhones) { Console.WriteLine(gsm); } //Display the information about the static property IPhone4S Console.WriteLine(GSM.IPhone4S.Model); Console.WriteLine(GSM.IPhone4S.Manufacturer); }
public static void PrintCallHistory(GSM myGsm) { foreach (var item in myGsm.CallHistory) { Console.WriteLine(item); } }
static void Main(string[] args) { GSM myPhone = new GSM("S6Edge", "Samsung", 100, "Pesho", new Battery("test"), new Display(10, 10)); Console.WriteLine(myPhone.ToString()); gsmTest.Test(); }
public static void TestCallHistory() { GSM myGSM = new GSM("Xperia S", "Sony", 700, "Slim Shady", new Battery(BatteryType.LiIon, "1750", 48, 24), new Display(4.3, 16000000)); var calls = new List <Call>(); calls.Add(new Call(DateTime.Now.AddDays(-2), "+359892412424", 99)); calls.Add(new Call(DateTime.Now.AddDays(-3).AddHours(3.5), "+359884631253", 123)); calls.Add(new Call(DateTime.Now.AddDays(-4), "+359874123173", 44)); foreach (var call in calls) { myGSM.AddCallToHistory(call); } Console.WriteLine(); myGSM.PrintCallHistory(); Console.WriteLine(); Console.WriteLine("Total price is: {0:C}", myGSM.GetTotalPriceOfCalls(0.37M)); myGSM.RemoveLongestCallFromHistory(); Console.WriteLine(); Console.WriteLine("Total price without the longest call is: {0:C}", myGSM.GetTotalPriceOfCalls(0.37M)); myGSM.ClearCallHistory(); Console.WriteLine(); myGSM.PrintCallHistory(); }
public static void TestCallHistory() { GSM myGSM = new GSM("Xperia S", "Sony", 700, "Slim Shady", new Battery(BatteryType.LiIon, "1750", 48, 24), new Display(4.3, 16000000)); var calls = new List<Call>(); calls.Add(new Call(DateTime.Now.AddDays(-2), "+359892412424", 99)); calls.Add(new Call(DateTime.Now.AddDays(-3).AddHours(3.5), "+359884631253", 123)); calls.Add(new Call(DateTime.Now.AddDays(-4), "+359874123173", 44)); foreach (var call in calls) { myGSM.AddCallToHistory(call); } Console.WriteLine(); myGSM.PrintCallHistory(); Console.WriteLine(); Console.WriteLine("Total price is: {0:C}", myGSM.GetTotalPriceOfCalls(0.37M)); myGSM.RemoveLongestCallFromHistory(); Console.WriteLine(); Console.WriteLine("Total price without the longest call is: {0:C}", myGSM.GetTotalPriceOfCalls(0.37M)); myGSM.ClearCallHistory(); Console.WriteLine(); myGSM.PrintCallHistory(); }
static void Main() { GSM[] gsm = new GSM[3]; Battery bat = new Battery("1sd34", 500, 100, BatteryType.NiCd); Display disp = new Display(); Battery anotherBat = new Battery(800, 200); Display anotherDisp = new Display(4.5, 20000000); gsm[0] = new GSM("IPhone 6S", "Apple", 1000.00, bat.ToString(), disp.ToString()); gsm[1] = new GSM("Galaxy S5", "Samsung", 620.00, "Ivan", anotherBat.ToString(), disp.ToString()); gsm[2] = new GSM("Nexus 5X", "LG", anotherBat.ToString(), anotherDisp.ToString()); foreach (var phone in gsm) { Console.WriteLine(phone.ToString()); Console.WriteLine(); } Console.WriteLine("========================="); Console.WriteLine(GSM.IPhone4S); Console.WriteLine("========================="); GSMCallHistoryTest test = new GSMCallHistoryTest(); test.Test(); }
static void Main(string[] args) { GSM currentGSM = new GSM("IPhone7", "Apple"); GSM currentGSM2 = new GSM("IPhone7", "Apple"); GSM currentGSM3 = new GSM("IPhone7", "Apple"); DateTime currentDate = new DateTime(2015, 12, 6, 6, 33, 0); Call firstCall = new Call(currentDate, "0887589423", 120); currentDate = currentDate.AddMinutes(30); Call secondCall = new Call(currentDate, "0878236732", 180); GSMTest someTest = new GSMTest(new GSM[] { currentGSM, currentGSM2, currentGSM3 }); }
static void PrintCallHistory(GSM newPhone) { if (newPhone.CallHistory.Count == 0) { Console.WriteLine("No Calls"); } for (int i = 0; i < newPhone.CallHistory.Count; i++) { Console.WriteLine($"Call number {i} happened on: {newPhone.CallHistory[i].DateAndTime}, it lasted: {newPhone.CallHistory[i].Duration} seconds and the conacted number was: {newPhone.CallHistory[i].DialledNumber}"); } }
public static void Test() { GSM[] gsmArr = new GSM[3] { GSM.iphone4s, GSM.iphone4s, GSM.iphone4s }; gsmArr[1].Owner = "Ivan"; gsmArr[2].Owner = "Petkan"; foreach (var gsm in gsmArr) { Console.WriteLine(gsm.ToString()); } }
public static void CallHistoryTest() { //creating GSMs var iPhone6 = new GSM("Apple", "iPhone 6"); var galaxyS6 = new GSM("Samsung", "Galaxy S 6"); var g3 = new GSM("LG", "G3"); //adding calls on each GSM's call history iPhone6.AddCall(new Call("21.05.2015 15:36:12", "+359888456891", 154)); iPhone6.AddCall(new Call("22.05.2015 18:38:12", "+359878475896", 35)); iPhone6.AddCall(new Call("25.05.2015 13:34:12", "+359898475126", 75)); galaxyS6.AddCall(new Call()); g3.AddCall(new Call("21.07.2015 15:36:12", "+359888476891", 78)); g3.AddCall(new Call("7.08.2015 10:25:22", "+359876554015", 45)); //printing call history and total price of calls Console.WriteLine(Environment.NewLine + iPhone6.Model); Console.WriteLine(iPhone6.CallHistory); Console.WriteLine(iPhone6.PriceOfCalls()); Console.WriteLine(Environment.NewLine + galaxyS6.Model); Console.WriteLine(galaxyS6.CallHistory); Console.WriteLine(galaxyS6.PriceOfCalls()); Console.WriteLine(Environment.NewLine + g3.Model); Console.WriteLine(g3.CallHistory); Console.WriteLine(g3.PriceOfCalls()); //deleting call with maximal duration and printing call history and total price of calls iPhone6.DeleteCall(); Console.WriteLine(Environment.NewLine + iPhone6.Model); Console.WriteLine(iPhone6.CallHistory); Console.WriteLine(iPhone6.PriceOfCalls()); g3.DeleteCall(); Console.WriteLine(Environment.NewLine + g3.Model); Console.WriteLine(g3.CallHistory); Console.WriteLine(g3.PriceOfCalls()); //clearin call histrory iPhone6.ClearHistory(); Console.WriteLine(Environment.NewLine + iPhone6.Model); Console.WriteLine(iPhone6.CallHistory); Console.WriteLine(iPhone6.PriceOfCalls()); g3.ClearHistory(); Console.WriteLine(Environment.NewLine + g3.Model); Console.WriteLine(g3.CallHistory); Console.WriteLine(g3.PriceOfCalls()); }
public static void CallTest() { // Create an instance of the GSM class. var newPhone = new GSM("test model", "random manufacturer"); // Add few calls. newPhone.AddCall(DateTime.Now, 500, "0888424124"); newPhone.AddCall(new DateTime(2016, 12, 31, 23, 58, 59), 1600, "0888444444"); newPhone.AddCall(new DateTime(2016, 12, 21, 11, 23, 01), 2600, "0888444333"); // Display the information about the calls. PrintCallHistory(newPhone); // Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history. // price is set as a constant in GSM class var totalPrice = newPhone.CalculateCallsPrice(); Console.WriteLine("You must pay: {0:F2} leva", totalPrice); // Remove the longest call from the history and calculate the total price again. int longestCall = 0; int indexLongestCall = 0; for (int i = 0; i < newPhone.CallHistory.Count; i++) { if (newPhone.CallHistory[i].Duration > longestCall) { longestCall = newPhone.CallHistory[i].Duration; indexLongestCall = i; } } newPhone.DeleteCall(indexLongestCall); var newPrice = newPhone.CalculateCallsPrice(); Console.WriteLine("You must pay: {0:F2} leva", newPrice); // Finally clear the call history and print it. newPhone.ClearHistory(); PrintCallHistory(newPhone); }
public static void Test() { var GSMs = new List<GSM>(); var myGSM = new GSM("Xperia Z", "Sony", 613, "Slim Shady", new Battery(BatteryType.LiIon, "2330", 550, 11), new Display(5.0, 16000000)); GSMs.Add(myGSM); var myGSM2 = new GSM("One", "HTC", 638, "Krali Marko", new Battery(BatteryType.LiPo, "2300", 500, 27), new Display(4.7, 16000000)); GSMs.Add(myGSM2); Console.WriteLine(myGSM.Display); foreach (var phone in GSMs) { Console.WriteLine(phone); Console.WriteLine(); } Console.WriteLine(GSM.IPhone4S.ToString()); }
public static void GSMCallHistoryTest() { GSM oboroten = new GSM("Nokia W8", "Nokia Corp.", 220, "Ivanchoy", new Battery("Zbot", 8, 3, BattertType.Li_Lon), new Display(4.2, 555000)); oboroten.AddCall(new DateTime(2015, 3, 15), "0893345323", 415); oboroten.AddCall(new DateTime(2015, 2, 10), "0881500162", 845); oboroten.AddCall(new DateTime(2015, 2, 10), "0875916442", 45); oboroten.AddCall(new DateTime(2015, 2, 11), "0891500156", 165); oboroten.AddCall(new DateTime(2015, 2, 6), "0891547400", 264); oboroten.AddCall(new DateTime(2015, 2, 5), "0881622317", 942); oboroten.AddCall(new DateTime(2015, 2, 9), "0879455161", 315); oboroten.AddCall(new DateTime(2015, 3, 15), "0893345323", 548); // call again to first number //Show calls oboroten.ShowCallListHystorY(); // Total calls Console.WriteLine("Total price is: ${0:F2}", oboroten.TotalPrice()); //Remove the longest call uint max = 0; int index = -1; foreach (var item in oboroten.CallsHistory) { if (item.Duration > max) { max = item.Duration; index = oboroten.CallsHistory.IndexOf(item); } } oboroten.DeleteCallAtPosition(index); // Caling again this metod oboroten.ShowCallListHystorY(); Console.WriteLine("After delete max duration call. Total price is: ${0:F2}", oboroten.TotalPrice()); // Clear the call list Console.WriteLine("Delete all calls..."); oboroten.ClearHystor(); oboroten.ShowCallListHystorY(); }
public static void Main() { //creating GSMs var iPhone6 = new GSM("Apple", "IPhone 6", 1499.99M, "Tim Cook", new Battery("Integrated", 100F, 10F, BatteryType.LiIon), new Display(4.7F, 16000000)); var galaxyS6 = new GSM("Samsung", "Galaxy S6"); //adding phones in an array GSM[] phones = { iPhone6, galaxyS6 }; //printing information of each phone foreach (var phone in phones) { Console.WriteLine(phone); Console.WriteLine(new string('-', 70)); } //printing information of iPhone4s Console.WriteLine(GSM.IPhone4S); GSMCallHistoryTest.CallHistoryTest(); }
public static void Test() { var GSMs = new List <GSM>(); var myGSM = new GSM("Xperia Z", "Sony", 613, "Slim Shady", new Battery(BatteryType.LiIon, "2330", 550, 11), new Display(5.0, 16000000)); GSMs.Add(myGSM); var myGSM2 = new GSM("One", "HTC", 638, "Krali Marko", new Battery(BatteryType.LiPo, "2300", 500, 27), new Display(4.7, 16000000)); GSMs.Add(myGSM2); Console.WriteLine(myGSM.Display); foreach (var phone in GSMs) { Console.WriteLine(phone); Console.WriteLine(); } Console.WriteLine(GSM.IPhone4S.ToString()); }
public static void TestGSM() { // Create an array of few instances of the GSM class. var arrayOfGsms = new GSM[3]; for (int i = 0; i < 3; i++) { arrayOfGsms[i] = new GSM("iphone", "Apple"); } // Display the information about the GSMs in the array. foreach (var phone in arrayOfGsms) { phone.ShowInfo(); } Console.WriteLine("====="); // Display the information about the static property IPhone4S GSM.IPhone4S.ShowInfo(); }
public void Test() { Battery bat = new Battery("1sd34", 500, 100, BatteryType.NiCd); Display disp = new Display(); GSM phone = new GSM("6", "IPhone", bat.ToString(), disp.ToString()); phone.AddCall("12.12.2012", "15:00", "+359 885 635338", 500); phone.AddCall("04.04.2004", "12:00", "+359 885 643453", 200); phone.AddCall("01.03.2014", "09:00", "+359 884 654634", 100); foreach (var item in GSM.CallList) { Console.WriteLine(item); } Console.WriteLine("Total price of all calls in history: " + phone.CalculateCallPrice(0.37) + "BGN"); Console.WriteLine("========================="); phone.DeleteCall(); foreach (var item in GSM.CallList) { Console.WriteLine(item); } Console.WriteLine("Total price of all calls in history: " + phone.CalculateCallPrice(0.37) + "BGN"); Console.WriteLine("========================="); phone.ClearHistory(); foreach (var item in GSM.CallList) { Console.WriteLine(item); } }
public void AddGSMForTesting(GSM gsm) { this.GSM = gsm; }
public GSMCallHistoryTest(GSM gsm) { this.GSM = gsm; }
public static void Test() { const decimal pricePerMinute = 0.37m; GSM myGsm = new GSM("Sony", "Experia e4"); myGsm.AddCallToHistory( new Call( new DateTime(2015, 2, 16, 21, 22, 3), "+3592 1111111111", new TimeSpan(0, 12, 45))); myGsm.AddCallToHistory( new Call( new DateTime(2015, 2, 17, 20, 22, 3), "+3592 2222222222", new TimeSpan(0, 10, 32))); myGsm.AddCallToHistory( new Call( new DateTime(2015, 2, 19, 17, 29, 35), "+3592 1111111111", new TimeSpan(0, 7, 3))); myGsm.AddCallToHistory( new Call( new DateTime(2015, 3, 1, 0, 48, 53), "+3592 3333333333", new TimeSpan(0, 17, 38))); Console.WriteLine(myGsm.ToString()); PrintCallHistory(myGsm); Console.WriteLine(); decimal priceOfCallHistory = myGsm.PriceOfCallHistory(pricePerMinute); Console.WriteLine("total price: {0:F4}", priceOfCallHistory); Console.WriteLine(); Call callToDelete = new Call( new DateTime(), "+3592 1111111111", new TimeSpan()); Console.WriteLine("deleting last call by number: {0}", callToDelete.DialedNumber); myGsm.DeleteCallByNumber(callToDelete); PrintCallHistory(myGsm); Console.WriteLine(); Console.WriteLine("deleting longest call"); myGsm.DeleteLongesCall(); PrintCallHistory(myGsm); priceOfCallHistory = myGsm.PriceOfCallHistory(pricePerMinute); Console.WriteLine("total price: {0:F4}", priceOfCallHistory); Console.WriteLine(); Console.WriteLine("clearing all history"); myGsm.ClearCallHistory(); PrintCallHistory(myGsm); Console.WriteLine("history cleared"); }
static void Main() { Battery firstBattery = new Battery("A2000", 500, 200, BatteryType.LiIon); Battery secondBattery = new Battery("B3000", 600, 300, BatteryType.NiCd); Battery thirdBattery = new Battery("C1000", 400, 100, BatteryType.NiMH); Display firstDisplay = new Display(5, 16000000); Display secondDisplay = new Display(4, 16000000); Display thirdDisplay = new Display(4.5, 16000000); //// GSM with all parameters GSM[] phones = new GSM[] { GSM.IPhone4S, new GSM("Idol 2", "Alcatel", 200, "P.Petrov", firstBattery, firstDisplay), new GSM("Galaxy Core 2", "Samsung", 250, "I.Ivanova", secondBattery, thirdDisplay), new GSM("P8 lite", "Huawei", 220, "P.Angelov", firstBattery, firstDisplay), new GSM("Lumia 800", "Nokia", 300, "A.Tokev", thirdBattery, secondDisplay) }; foreach (var phone in phones) { Console.WriteLine(phone); Console.WriteLine(); } //GSM with some missing parameters GSM[] secondPhonesArr = new GSM[] { new GSM("Idol 2", "Alcatel", 200), new GSM("Galaxy Core 2", "Samsung", null, "I.Ivanova"), new GSM("P8 lite", "Huawei", 220, "P.Angelov", firstBattery, firstDisplay), new GSM("Lumia 800", "Nokia", 300, "A.Tokev", thirdBattery, secondDisplay) }; foreach (var phone in secondPhonesArr) { Console.WriteLine(phone); Console.WriteLine(); } // Call history Tests GSM somePhone = new GSM("3310", "Nokia"); somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888123456", 45)); somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888111111", 15)); somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888222222", 55)); somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888333333", 65)); somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888444444", 110)); somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888555555", 20)); somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888666666", 40)); Console.WriteLine(somePhone.ShowCallHistory()); Console.WriteLine(somePhone.CallsPrice(0.37)); Console.WriteLine(); somePhone.RemoveCall(5); Console.WriteLine(somePhone.ShowCallHistory()); Console.WriteLine(somePhone.CallsPrice(0.37)); Console.WriteLine(); somePhone.ClearCallHistory(); Console.WriteLine(somePhone.ShowCallHistory()); }