//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(); }
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() { 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(); }
//protected method public void Tests() { for (int i = 0; i < 3; i++) { GSM phone = new GSM(this.models[i], this.manifacturers[i], this.price[i], this.owners[i], this.battery[i], this.display[i]); Console.WriteLine(phone.ToString()); Console.WriteLine(""); } Console.WriteLine("Iphone4S ---------------------------------- "); Console.WriteLine(GSM.IPhone4S); }
static void Main() { try { //adding battery type i the battery constructor Battery batteryOne = new Battery("SameModel", 10, 20, BatteryType.LiIon); Console.WriteLine("-------------------------EX3---------------------------"); Console.WriteLine(batteryOne.Type); // creating phone Display displayOne = new Display(55f); GSM gsm = new GSM("55k33", "Nokia", 666, "Nqkoi", batteryOne, displayOne); // test for override method ToString() Console.WriteLine("-------------------------EX4---------------------------"); Console.WriteLine(gsm.ToString()); Console.WriteLine("-------------------------EX.7--------------------------"); //creating object test GSMTests test = new GSMTests(); test.Tests();//call its method It is void method so it will directly write the data //ex.9 Console.WriteLine("------------------------EX9---------------------------"); string dateTime ="22.12.2013 01.05.35"; DateTime day = DateTime.ParseExact(dateTime, "dd.MM.yyyy HH.mm.ss", CultureInfo.InvariantCulture);//date string dateTime2 = "20.12.2013 01.05.35"; DateTime day2 = DateTime.ParseExact(dateTime2, "dd.MM.yyyy HH.mm.ss", CultureInfo.InvariantCulture);//date Call firstCall = new Call(day,"0555555555",78); Call secondCall = new Call(day2, "0555555555", 105); Console.WriteLine(firstCall.DateAndTime); gsm.AddCalls(firstCall); gsm.AddCalls(secondCall); Console.WriteLine(); Console.WriteLine(gsm.CallHistory[0].DateAndTime); Console.WriteLine(gsm.CallHistory[1].DateAndTime); Console.WriteLine("------------------------EX10--------------------------"); gsm.DeleteCall(secondCall); for (int i = 0; i < gsm.CallHistory.Count; i++) { Console.WriteLine(gsm.CallHistory[i].DateAndTime); } gsm.ClearCallHistory(); Console.WriteLine("There is {0} call in the call history",gsm.CallHistory.Count); Console.WriteLine("--------------------------EX12------------------------"); GSMCallHistoryTest testHistory = new GSMCallHistoryTest(); testHistory.GSMCallHistoryTests(); } catch (ArgumentException exep) { Console.WriteLine("There is incorrect data!"); Console.WriteLine(exep.ToString()); } }
static void Main() { Person pesho = new Person("Pesho"); Display display = new Display(5.4, 16000); Battery battery = new Battery("5KR76", 6.4, 4.1, BatteryType.NiCd); GSM gsm = new GSM("C30", "Nokia", 45.46m, pesho, battery, display); //GSM gsm = new GSM("C30", "Nokia", owner: pesho, display: display); Console.WriteLine(gsm.ToString()); Console.WriteLine(GSM.IPhone4S.ToString()); }
static void Main() { //Create an instance of the GSM class. GSM myPhone = new GSM("One", "One Plus"); myPhone.Owner = "I"; myPhone.Price = 1000; myPhone.DisplaySize = 5; myPhone.DisplayNumberOfColors = 16000000; myPhone.battery.Type = BatteryType.LiIon; myPhone.battery.Model = "RBC18"; myPhone.battery.HoursIdleTime = 426.5; myPhone.battery.HoursTalkTime = 24.3; myPhone.AddCallToList(new Call(DateTime.Now, "0885649596", 5)); //Add few calls. for (int i = 10; i < 60; i = i + 5) { myPhone.AddCallToList(new Call(DateTime.Now.AddMinutes(i), "08856495" + i, i)); } for (int i = 80; i > 65; i = i - 3) { myPhone.AddCallToList(new Call(DateTime.Now.AddMinutes(i), "08856495" + i, i)); } Console.WriteLine(myPhone.ToString()); //Display the information about the calls. foreach (var call in myPhone.CallHistory) { Console.WriteLine("{0} - Phone number: {1} - Duration: {2}", call.Time, call.PhoneNumber, call.Duration); } Console.WriteLine("Total talk time: {0}", myPhone.TotalTalkTime()); //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history. Console.WriteLine("The total price of the calls in the history is : {0}", myPhone.CallPrice(0.37M)); //Remove the longest call from the history and calculate the total price again. myPhone.DeleteCallFromList(FindLongestCall(myPhone.CallHistory)); foreach (var call in myPhone.CallHistory) { Console.WriteLine("{0} - Phone number: {1} - Duration: {2}", call.Time, call.PhoneNumber, call.Duration); } Console.WriteLine("Total talk time: {0}", myPhone.TotalTalkTime()); Console.WriteLine("The total price of the calls in the history is : {0}", myPhone.CallPrice(0.37M)); //Finally clear the call history and print it. myPhone.ClearCallHistory(); foreach (var call in myPhone.CallHistory) { Console.WriteLine("{0} - Phone number: {1} - Duration: {2}", call.Time, call.PhoneNumber, call.Duration); } Console.WriteLine("Total talk time: {0}", myPhone.TotalTalkTime()); Console.WriteLine("The total price of the calls in the history is : {0}", myPhone.CallPrice(0.37M)); }
static void Main() { GSM phone = new GSM("Moto X", "Motorola"); phone.AddCall(DateTime.Now, "0899789987", 500); phone.AddCall(new DateTime(2013, 2, 16), "0899233987", 350); phone.AddCall(new DateTime(2013, 2, 12), "0899123456", 58); phone.AddCall(new DateTime(2013, 2, 13), "0899123456", 58); phone.AddCall(new DateTime(2013, 2, 14), "0899123456", 69); phone.AddCall(new DateTime(2013, 2, 14), "0899123456", 69); Console.WriteLine(phone.ToString()); phone.ShowCallHistory(); phone.CalcPrice(0.37M); phone.RemoveLongestCall(); phone.CalcPrice(0.37M); phone.ClearHistory(); phone.ShowCallHistory(); }
static void Main(string[] args) { GSM LG = new GSM("G2"); LG.Manufacturer = "LG"; LG.Owner = "Alexander"; LG.Price = 450; string lgModel = LG.Model; Console.WriteLine(LG.ToString()); GSM iPhone4S = new GSM("IPhone4S"); iPhone4S.Manufacturer = "Apple"; iPhone4S.Owner = "My neighbour"; iPhone4S.Price = 1450; string iphoneModel = iPhone4S.Model; Console.WriteLine(iPhone4S.ToString()); }
static void Main() { GSM myGSM = new GSM("C2-01", "Nokia"); Console.WriteLine(myGSM.ToString()); }
static void Main() { GSM gsm = new GSM("Galaxy S3", "Samsung", 899.99m, "30 milion people"); string gsmString = gsm.ToString(); Console.WriteLine(gsm); }
//metod print public void PrintGSMInfo(GSM gsm) { Console.WriteLine(gsm.ToString()); }
static void Main() { GSM Samsung = new GSM("iphone", 1200, "Apple", "Pesho"); Console.WriteLine(Samsung.ToString()); }
static void Main() { try { Battery batteryOne = new Battery("SameModel", 10, 20, BatteryType.LiIon); Display displayOne = new Display(55f); GSM gsm = new GSM("55k33", "Nokia", 666, "Nqkoi", batteryOne, displayOne); Console.WriteLine(gsm.ToString()); // Console.WriteLine(batteryOne.Type); //ex.6 Console.WriteLine(); } catch (ArgumentException exep) { Console.WriteLine("There is incorrect data!"); Console.WriteLine(exep.ToString()); } }
static void Main() { GSM iPhone = new GSM("iphone", 1200, "Apple", "Az"); Console.WriteLine(iPhone.ToString()); string hghgf = null; Console.WriteLine(hghgf); }
static void Main() { GSM[] gsmArray = { new GSM("S3", "Galaxy", 710M, "Reni", new Battery("A12", 20, 5, BatteryType.LiIon), new Display(4.8, 50000)), new GSM("5", "Nexus", 610M, "Stasko", new Battery("A13", 19, 6, BatteryType.NiCd), new Display(5, 40000)), }; foreach (var gsm in gsmArray) { Console.WriteLine(gsm.ToString()); Console.WriteLine(new string('-', 50)); } Console.WriteLine("Static property: {0}", GSM.IPhone4S); GSM myGSM = new GSM("Xperia", "Sony", 510M, "Didi", new Battery("A14", 15, 7, BatteryType.NiMH), new Display(4.9, 45000)); List<Call> callHistory = new List<Call> { new Call(new DateTime(2015, 03, 18), new Time(23, 22, 56), "0888123456", 360), new Call(new DateTime(2015, 02, 19), new Time(13, 19, 25), "0888124556", 520), new Call(new DateTime(2015, 01, 15), new Time(11, 10, 20), "0888124106", 800) }; //add calls to call history list foreach (var call in callHistory) { myGSM.AddCall(call); } Console.WriteLine(myGSM.ToString()); myGSM.CallHistory.Add(new Call(new DateTime(2015, 01, 15), new Time(11, 10, 20), "0888124106", 800)); //print call history myGSM.PrintCallHistory(); //calculate total price and print it decimal totalPrice = myGSM.CallPrice(myGSM.CallHistory, 0.37M); Console.WriteLine("Total call's price: {0}", totalPrice); //remove the longest call from the history Call longestCall = new Call(); foreach (var call in callHistory) { if (longestCall.Duration <= call.Duration) { longestCall = call; } } //delete longest call myGSM.DeleteCall(longestCall); myGSM.PrintCallHistory(); //calculate the total price again totalPrice = myGSM.CallPrice(myGSM.CallHistory, 0.37M); Console.WriteLine("Total call's price: {0}", totalPrice); //clear the call history and print it. myGSM.ClearHistory(); myGSM.PrintCallHistory(); }
public static void Main() { //Console.Write("Enter number of phones: "); //int number = int.Parse(Console.ReadLine()); //GSM[] phones = new GSM[number]; //for (int i = 0; i < number; i++) //{ // Console.Write("Enter phone model: "); // string model = Console.ReadLine(); // Console.Write("Enter phone manifacutrer: "); // string manifacture = Console.ReadLine(); // Console.Write("Enter phone owner: "); // string owner = Console.ReadLine(); // Console.Write("Enter phone price: "); // string price = Console.ReadLine(); // Console.Write("Enter phone batter model: "); // string batteryModel = Console.ReadLine(); // Console.Write("Enter phone battery idle hours: "); // string idleHours = Console.ReadLine(); // Console.Write("Enter phone battery talk hours: "); // string talkHours = Console.ReadLine(); // Console.Write("Enter phone display size: "); // string displaySize = Console.ReadLine(); // Console.Write("Enter phone number of colors: "); // string displayColors = Console.ReadLine(); // phones[i] = new GSM(model, manifacture, owner, double.Parse(price), batteryModel, int.Parse(idleHours), int.Parse(talkHours), double.Parse(displaySize), int.Parse(displayColors)); //} //foreach (var item in phones) //{ // Console.WriteLine(); // item.GetInfo(); //Console.WriteLine(item.ToString()); // Console.WriteLine(); //} //---------------------------------------------------------------------------------------------------// //CallHistoryTest GSM mobile = new GSM("3310", "Nokia", "Some swedish guy", 100m, "ARhd34", 310, 140, 4.3f, 16000000, BatteryType.LiIon); Console.WriteLine(mobile.ToString()); //mobile.GetInfo(); mobile.AddCalls("12:50", 0894216738, 50, 21, 12, 2013); mobile.AddCalls("16:23", 0894216738, 120, 21, 12, 2013); mobile.AddCalls("18:32", 0894216738, 23, 24, 12, 2013); mobile.AddCalls("12:17", 0894216738, 180, 29, 12, 2013); //Get info for the calls Console.WriteLine(); foreach (var item in mobile.callHistory) { Console.WriteLine(item.date + " " + item.dialedNumber + " " + item.duration + " " + item.Time); } //Print total price Console.WriteLine(); Console.WriteLine("Total price: {0}", mobile.CalculateTotalBill(0.37m)); //Delete longest call and print price again mobile.callHistory.Remove(mobile.callHistory[3]); Console.WriteLine(); Console.WriteLine("Total price: {0}", mobile.CalculateTotalBill(0.37m)); //Clear call history and print again mobile.callHistory.Clear(); Console.WriteLine(); foreach (var item in mobile.callHistory) { Console.WriteLine(item.date + " " + item.dialedNumber + " " + item.duration + " " + item.Time); } }
static void Main() { GSM[] gsmArray = { new GSM("S3", "Galaxy", 710M, "Reni", new Battery("A12", 20, 5, BatteryType.LiIon), new Display(4.8, 50000)), new GSM("5", "Nexus", 610M, "Stasko", new Battery("A13", 19, 6, BatteryType.NiCd), new Display(5, 40000)), }; foreach (var gsm in gsmArray) { Console.WriteLine(gsm.ToString()); Console.WriteLine(new string('-', 50)); } Console.WriteLine("Static property: {0}", GSM.IPhone4S); GSM myGSM = new GSM("Xperia", "Sony", 510M, "Didi", new Battery("A14", 15, 7, BatteryType.NiMH), new Display(4.9, 45000)); List <Call> callHistory = new List <Call> { new Call(new DateTime(2015, 03, 18), new Time(23, 22, 56), "0888123456", 360), new Call(new DateTime(2015, 02, 19), new Time(13, 19, 25), "0888124556", 520), new Call(new DateTime(2015, 01, 15), new Time(11, 10, 20), "0888124106", 800) }; //add calls to call history list foreach (var call in callHistory) { myGSM.AddCall(call); } Console.WriteLine(myGSM.ToString()); myGSM.CallHistory.Add(new Call(new DateTime(2015, 01, 15), new Time(11, 10, 20), "0888124106", 800)); //print call history myGSM.PrintCallHistory(); //calculate total price and print it decimal totalPrice = myGSM.CallPrice(myGSM.CallHistory, 0.37M); Console.WriteLine("Total call's price: {0}", totalPrice); //remove the longest call from the history Call longestCall = new Call(); foreach (var call in callHistory) { if (longestCall.Duration <= call.Duration) { longestCall = call; } } //delete longest call myGSM.DeleteCall(longestCall); myGSM.PrintCallHistory(); //calculate the total price again totalPrice = myGSM.CallPrice(myGSM.CallHistory, 0.37M); Console.WriteLine("Total call's price: {0}", totalPrice); //clear the call history and print it. myGSM.ClearHistory(); myGSM.PrintCallHistory(); }
static void Main(string[] args) { GSM justInstance = new GSM(); //Testing full parameter ctor Console.WriteLine(new string('-', 80)); GSM Nokia = new GSM("E52", "Nokia", 200.0m, "Ivan", new Battery("2000 mAh", 12.3, 4.5, BatteryType.NiMH), new Display(2.6, 16000000)); Console.WriteLine("\nTesting full parameter ctor"); Console.WriteLine(Nokia.ToString()); //Testing full param ctor with default Battery and Display Console.WriteLine(new string('-', 80)); GSM Nokia1 = new GSM("E52", "Nokia", 200.0m, "Ivan", new Battery(), new Display()); Console.WriteLine("\nTesting full param ctor with default Battery and Display"); Console.WriteLine(Nokia1.ToString()); //Testing partial param ctor Console.WriteLine(new string('-', 80)); GSM Nokia2 = new GSM("E52", "Nokia"); Console.WriteLine("\nTesting partial param ctor"); Console.WriteLine(Nokia2.ToString()); ///////////////////////////TASK 7 tests////////////////////////////// Console.WriteLine(new string('-', 80)); Console.WriteLine("\nTASK 7 TEST START HERE !"); GSM[] gsmList = new GSM[5]; for (int i = 0; i < 5; i++) { gsmList[i] = Nokia; } foreach (GSM gsm in gsmList) { Console.WriteLine(gsm.ToString() + "\n"); } Console.WriteLine("\nPrinting static field iPhone4s"); Console.WriteLine(justInstance.IPhone4s); ///////////////////////////TASK 10 tests//////////////////////////// Console.WriteLine(new string('-', 80)); Console.WriteLine("\nTASK 10 TEST START HERE !"); GSM vladosPhone = new GSM("S35", "Siemens", 79.99m, "Vlado", new Battery("750mAh", 72, 6, BatteryType.LiIon), new Display(1.5, 64), null); vladosPhone.AddCalltoHistory(new Call("+359888555777",3600)); vladosPhone.AddCalltoHistory(new Call("0000",0)); vladosPhone.AddCalltoHistory(new Call("+359888000000",15)); vladosPhone.AddCalltoHistory(new Call("0888555777",10)); vladosPhone.AddCalltoHistory(new Call("028685512",20)); vladosPhone.AddCalltoHistory(new Call("0359887551552",60)); vladosPhone.PrintCallLog(); vladosPhone.DeleteCallFromHistory(new Call("+359888555777")); vladosPhone.DeleteCallFromHistory(new Call("0000")); vladosPhone.DeleteCallFromHistory(new Call("+359888000000")); Console.WriteLine("Testing callHistory delete function:"); vladosPhone.PrintCallLog(); Console.WriteLine("Testing callHistory clear function:"); vladosPhone.ClearHistory(); vladosPhone.PrintCallLog(); ///////////////////////////TASK 11 tests//////////////////////////// Console.WriteLine(new string('-', 80)); Console.WriteLine("\nTASK 11 TEST START HERE !"); vladosPhone.AddCalltoHistory(new Call("+359888555777", 3600)); vladosPhone.AddCalltoHistory(new Call("+359888000000", 15)); vladosPhone.AddCalltoHistory(new Call("0359887551552", 60)); vladosPhone.CalculatePrice(); ///////////////////////////TASK 12 tests//////////////////////////// Console.WriteLine(new string('-', 80)); Console.WriteLine("\nTASK 12 TEST START HERE !"); /* 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. */ //Create an instance of the GSM class. GSM instance = new GSM(); // Add few calls. instance.AddCalltoHistory(new Call("+359888555777", 3600)); instance.AddCalltoHistory(new Call("+359888123321", 300)); instance.AddCalltoHistory(new Call("0359888333222", 80)); instance.AddCalltoHistory(new Call("028683939", 50)); instance.AddCalltoHistory(new Call("+123000128937912837", 0)); // Display the information about the calls. instance.PrintCallLog(); //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history. instance.CalculatePrice(); //Remove the longest call from the history and calculate the total price again. instance.DeleteCallFromHistory(new Call("+359888555777")); instance.CalculatePrice(); // Finally clear the call history and print it. instance.ClearHistory(); instance.PrintCallLog(); }