public static void CallHistoryTest() { GSMobile phone = new GSMobile("Galaxy S7", "Samsung", 949.99m, "Papa", new Battery("Removable", BatteryType.NiCd, 100, 11), new Display(6.5f, 16)); Console.WriteLine(phone.ToString()); phone.AddCall(DateTime.Now, "+35900472475", 583); phone.AddCall(DateTime.Now, "+9584635244757", 115); phone.AddCall(DateTime.Now, "+9583652758", 18); phone.CallHistoryView(); Console.WriteLine("The total prise is ${0:f2} ", phone.TotalPrice()); Call one = new Call(DateTime.Now, "+35900472475", 583); phone.RemoveCall(one); phone.CallHistoryView(); Console.WriteLine("The total prise after removing of one element is ${0:f2} ", phone.TotalPrice()); phone.ClearCallHistory(); phone.CallHistoryView(); Console.WriteLine("The total prise after clearing list is ${0:f2} ", phone.TotalPrice()); }
static void Main() { Battery myBattery = new Battery("B. M.", 15, 56, BatteryType.NiMH); Battery myBattery1 = new Battery("B. M.", 17, 68, BatteryType.LiIon); Battery myBattery2 = new Battery("B. M.", 16, 69, BatteryType.NiCd); GSM gsm = new GSM("S6", "Samsung", 500.03m, "Pesho", myBattery); Console.WriteLine(gsm + "\n"); Console.WriteLine(GSM.IPhone + "\n"); GSM gsm1 = new GSM("S1", "Samsung", 100.09m, "Pesho", myBattery); GSM gsm2 = new GSM("S2", "Samsung", 200.09m, "Pesho", myBattery1); GSM gsm3 = new GSM("S3", "Samsung", 300.09m, "Pesho", myBattery2); GSM gsm4 = new GSM("S4", "Samsung", 400.09m, "Pesho", myBattery1); List<GSM> gsmList = new List<GSM>() { gsm1, gsm2, gsm3, gsm4 }; foreach (var telephone in gsmList) { Console.WriteLine(telephone); } DateTime date1 = new DateTime(2008, 8, 29, 19, 27, 15, 18); DateTime date2 = new DateTime(2014, 8, 30, 19, 22, 15, 18); DateTime date3 = new DateTime(2014, 9, 15, 10, 12, 14, 44); CultureInfo ci = CultureInfo.InvariantCulture; Call call1 = new Call(date1, date1, "+359878864612", 120); Call call2 = new Call(date2, date2, "+359871164612", 820); Call call3 = new Call(date3, date3, "+359872264612", 320); gsm.AddCall(call1); gsm.AddCall(call2); gsm.AddCall(call3); var calls = gsm.GetCalls(); gsm.DisplayCallsInfo(); Console.WriteLine("\nTotal price of the calls in the history is {0} BGN\n", gsm.CallPrice()); var longestCall = calls.OrderByDescending(x => x.CallDurationInSeconds).First(); gsm.DeleteCall(longestCall); Console.WriteLine("Phone call deleted"); Console.WriteLine("\nTotal price of the calls in the history is {0} BGN\n", gsm.CallPrice()); gsm.ClearCallHistory(); gsm.DisplayCallsInfo(); }
static void Main() { const int TestLenOfArray = 10; //max length of test array List<GSM> testGSMArray = new List<GSM>(); // declare test array of instances of the GSM class Battery newBattery = new Battery("C6603", 530, 11, BatteryType.LiIon); // create instance of Battery class Display newDisplay = new Display(5, 16000000); // create instance of Display class //initialize testGSMArray for (int i = 0; i < TestLenOfArray; i++) { GSM gsm = new GSM("Xperia Z", "Sony", 680.00m, "Pesho", newBattery, newDisplay); testGSMArray.Add(gsm); } testGSMArray[0].Owner = "Gogo"; //test throw exception //testGSMArray[0].Price = -1000; //test throw exception //newBattery.HoursTalk = -1; //test GSM for (int i = 0; i < TestLenOfArray; i++) { Console.WriteLine("_________________________________________"); testGSMArray[i].PrintAllInfoGSM(); Console.WriteLine("_________________________________________"); } GSM newGsm = new GSM("Xperia Z", "Sony", 680.00m, "Tosho", newBattery, newDisplay); Console.WriteLine(newGsm.IPhone4S); //TODO method for printing static property //test calls Call firstCall = new Call("+359888445522", 300); Call secondCall = new Call("+359888445521", 800); Call thirdCall = new Call("+359888445523", 700); Console.WriteLine("Calls History:"); testGSMArray[0].AddCallsINHistory(firstCall); Console.Write("Price:{0} BGN ", testGSMArray[0].ClacPriceofCalls(firstCall)); Console.WriteLine(testGSMArray[0].CallHistory[0].ToString()); testGSMArray[0].AddCallsINHistory(secondCall); Console.Write("Price:{0} BGN ", testGSMArray[0].ClacPriceofCalls(secondCall)); Console.WriteLine(testGSMArray[0].CallHistory[1].ToString()); testGSMArray[0].AddCallsINHistory(thirdCall); Console.Write("Price:{0} BGN ", testGSMArray[0].ClacPriceofCalls(thirdCall)); Console.WriteLine(testGSMArray[0].CallHistory[2].ToString()); decimal totalBill = 0.0m; for (int i = 0; i < testGSMArray[0].CallHistory.Count; i++) { totalBill += testGSMArray[0].ClacPriceofCalls(testGSMArray[0].CallHistory[i]); } Console.WriteLine("Total Bill:{0}", totalBill); uint maxDuration = 0; string maxDurCallId = String.Empty; //TODO method for calc total price for (int i = 0; i < testGSMArray[0].CallHistory.Count-1; i++) { if(testGSMArray[0].CallHistory[i].CallDuration > maxDuration) { maxDuration = testGSMArray[0].CallHistory[i].CallDuration; maxDurCallId = testGSMArray[0].CallHistory[i].Id; } } Console.WriteLine("_____________"); testGSMArray[0].DeleteCallsHistory(maxDurCallId); testGSMArray[0].PrintCallHistory(); totalBill = 0.0m; for (int i = 0; i < testGSMArray[0].CallHistory.Count; i++) { totalBill += testGSMArray[0].ClacPriceofCalls(testGSMArray[0].CallHistory[i]); } Console.WriteLine("Total bill without longest call:{0}", totalBill); Console.WriteLine("_____________"); testGSMArray[0].ClearCallsHistory(); testGSMArray[0].PrintCallHistory(); }
public void RemoveCall(Call current) { Call itemForRem = callHistory.Find( i => i.Date == current.Date && i.Time ==current.Time && i.DialledPhoneNr ==current.DialledPhoneNr && i.Duration == current.Duration); callHistory.Remove(itemForRem); }
public List<Call> DeleteCalls(Call call) { this.CallHistory.Remove(call); return this.CallHistory; }
public void AddCalls(Call call) { this.CallHistory.Add(call); }
public void DeleteCall(Call call) { this.CallHistory.Remove(call); }
//Task 10 public List<Call> AddCalls(Call element) { this.callHistory.Add(element); return this.callHistory; }
public void AddCallsINHistory(Call addNewCall) { this.callHistory.Add(addNewCall); }
public void DeleteCall(Call someCall) { this.CallHistory.Remove(someCall); }
public void AddCall(Call someCall) { this.CallHistory.Add(someCall); }
public void RemoveCall(Call call) { callHistory.Remove(call); }
public void AddCall(Call call) { callHistory.Add(call); }
public void AddCall(Call call) { if (this.CallHistory == null) { this.CallHistory = new List<Call>(); } this.CallHistory.Add(call); }
public List<Call> DellCalls(Call element) { this.callHistory.Remove(element); return this.callHistory; }
public decimal ClacPriceofCalls(Call currentCall) { return Math.Round(currentCall.CallDuration * (fixedPriceCalls/60), 2); }
public void AddCall(string phone, int duration) { Call call = new Call(DateTime.Now, phone, duration); callHistory.Add(call); }
public void RemoveFromCallHistory(Call call) { callHistory.Remove(call); }