public static void CallHistoryTest() { //Create an instance of the GSM class. GSM myGsm = GSM.IPhone4S; //Add few calls. Call someCall = new Call(DateTime.Now, 120, "+359888888888"); myGsm.AddCall(someCall); myGsm.AddCall(someCall); myGsm.DeleteCall(someCall); myGsm.AddCall(someCall); myGsm.AddCall(new Call(new DateTime(2013, 2, 10, 21, 14, 29), 1000, "0885088508")); myGsm.AddCall(new Call(new DateTime(2013, 1, 20, 11, 11, 11), 1000, "0885088508")); myGsm.AddCall(new Call(DateTime.Now, 119, "+359887121314")); //Display the information about the calls. Console.WriteLine("All calls:"); myGsm.PrintAllCalls(); //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history. PrintCallPrice(myGsm); //Remove the longest call from the historyand calculate the total price again. myGsm.RemoveLongestDurationCall(); Console.WriteLine("\nAfter remove of longest duration call..."); PrintCallPrice(myGsm); //Finally clear the call history and print it. myGsm.ClearCallHistory(); Console.WriteLine("\nAfter clear..."); myGsm.PrintAllCalls(); PrintCallPrice(myGsm); }
static public void AddCall() { Call thisCall = new Call(); string anotherCall = null; Console.WriteLine(); Console.WriteLine("You're in mode: Add Call"); Console.WriteLine(); Console.Write("Enter Date of the call:"); thisCall.Date = Console.ReadLine(); Console.Write("Enter the time when the call was made:"); thisCall.Time = Console.ReadLine(); Console.Write("Enter Phone number of the call reciver:"); thisCall.DialedNumber = Console.ReadLine(); Console.Write("Enter duration of the call(in seconds):"); thisCall.Duration = int.Parse(Console.ReadLine()); if (max < thisCall.Duration) { max = thisCall.Duration; indexOfLongestCall++; //use this index to dell the longest call later in the 'RemoveCall' method } thisCall = new Call(thisCall.Date, thisCall.Time, thisCall.DialedNumber, thisCall.Duration);//invoke full argument constructor of class 'Call' CallHistory.Add(thisCall);//add the call in List<Call> Console.WriteLine(); Console.Write("Add another call? Type 'yes' to proceed('no' for exit): "); anotherCall = Console.ReadLine().ToLower(); if (anotherCall.Equals("yes")) { //Bill(); GSM.AddCall(); } }
public static void AddCalls(GSM gsm) { Call[] callArray = new Call[3]; callArray[0] = new Call(DateTime.Now, "0889123456", 5); callArray[1] = new Call(DateTime.Now, "0889123455", 12); callArray[2] = new Call(DateTime.Now, "0878536897", 3); for (int index = 0; index < callArray.Length; index++) { gsm.AddCall(callArray[index]); } }
public static void RemoveLongestCall() { Call longestCall = new Call(DateTime.Now, "0", 0); for (int i = 0; i < testCalls.Length; i++) { if (testCalls[i].Duration >= longestCall.Duration) { longestCall = testCalls[i]; } } testGSM.DeleteCalls(longestCall); }
static void Main(string[] args) { //zad.7 GSMTest.PrintInfo(); //Create an instance of the GSM class. GSM myPhone = new GSM("N95", "Nokia"); //Add few calls. Call call = new Call(DateTime.Now, "0883333333", 60); Call nextCall = new Call(new DateTime(2013,02,10,20,34,20), "+3592376541212", 120); myPhone.AddCall(call); myPhone.AddCall(nextCall); //Display the information about the calls. foreach (var c in myPhone.CallHistory) { Console.WriteLine(c); } //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history. Console.Write("The total price of the calls is: "); myPhone.PriceOfCalls(0.37m); //Remove the longest call from the history and calculate the total price again. Call longest = new Call(); longest.Duration = 0; for (int i = 0; i < myPhone.CallHistory.Count; i++) { if (myPhone.CallHistory[i].Duration > longest.Duration) { longest = myPhone.CallHistory[i]; } } myPhone.RemoveCall(longest); Console.Write("The new price after removing longest call is: "); myPhone.PriceOfCalls(0.37m); //Finally clear the call history and print it. myPhone.ClearCallHistory(); foreach (var c in myPhone.CallHistory) { Console.WriteLine(c); } }
public void Test() { GSM iPhone = GSM.IPhone4S; //Add Calls Call newCaller = new Call("10.02.2012", "17:00", "0886254882", 600); Call newCaller2 = new Call("11.12.2012", "17:00", "0886254882", 2500); Call newCaller3 = new Call("08.08.2012", "18:00", "0886254882", 600); iPhone.AddCall(newCaller); iPhone.AddCall(newCaller2); iPhone.AddCall(newCaller3); //Print CallHistory StringBuilder testOutput = new StringBuilder(); foreach (var call in iPhone.CallHistory) { string callStr = call.ToString(); testOutput.Append(callStr); testOutput.Append("\n\r"); } Console.WriteLine(testOutput.ToString()); //Calculate Price decimal price = iPhone.CalculatePrice(0.37m); Console.WriteLine("{0:F2}лв.", price); //Remove one Call from CallHistory iPhone.RemoveCall(1); testOutput.Remove(0, testOutput.Length); foreach (var call in iPhone.CallHistory) { string callStr = call.ToString(); testOutput.Append(callStr); testOutput.Append("\n\r"); } Console.WriteLine(testOutput.ToString()); //Calculate New Price price = iPhone.CalculatePrice(0.37m); Console.WriteLine("{0:F2}лв.", price); //Clear CallHistory iPhone.EmptyCallHistory(); }
static void Main(string[] args) { var ipPhone6 = new GSM(model: "IP-Phone6", manufacturer: "xApple"); var salamSumng = new GSM(model: "Jalacxy7", manufacturer: "SalamSung"); var listFromSmartPhones = new List<GSM>(); listFromSmartPhones.Add(ipPhone6); listFromSmartPhones.Add(salamSumng); foreach (var phones in listFromSmartPhones) { Console.WriteLine(phones); } var iPhone4s = GSM.IPhone4s; var firstTestCall = new Call() { TimeStart = DateTime.Now, TimeEnd = DateTime.Now.AddMinutes(2), ItsIncomming = false, PhoneNumber = "0043123123" }; var duration = firstTestCall.Duration(); var secondTestCall = new Call() { TimeStart = DateTime.Now, TimeEnd = DateTime.Now.AddMinutes(3), ItsIncomming = false, PhoneNumber = "0043123123" }; ipPhone6.AddCall(firstTestCall); ipPhone6.AddCall(secondTestCall); decimal pricePerMinute = 0.37M; var totalPrice = ipPhone6.CallPrice(pricePerMinute); Console.WriteLine("Total call price: " + totalPrice); }
public void AddCall() { Call addCall = new Call(); this.callHistory.Add(addCall); }
public void AddCall(Call call) { List<Call> tempCallHistory = new List<Call>(this.CallHistory); tempCallHistory.Add(call); this.CallHistory = tempCallHistory; }
public void ClearCallHistory(Call call) { this.calls.Clear(); }
public void RemoveCall(Call call) { for (int i = 0; i < callHistory.Count; i++) { if (call.Duration == callHistory[i].Duration) { callHistory.RemoveAt(i); } } }
//Add CallHistory public void AddCall(Call newCall) { if (callHistory == null) { callHistory = new List<Call>(); callHistory.Add(newCall); } else { callHistory.Add(newCall); } }
public int DeleteCallFromHistory(Call call) { if (call == null) { throw new ArgumentNullException(@"Trying to delete ""null"" call."); } for (int i = 0; i < callHistory.Count; i++) { if (callHistory[i].Date == call.Date && callHistory[i].Time == call.Time && callHistory[i].DailedPhone == call.DailedPhone) { callHistory.RemoveAt(i); return 1; } } return -1; }
public Call DelleteCall(Call call) { this.callHistory.Remove(call); return call; }
/// <summary> /// Closes a call - ends the last opened call from the call list. /// </summary> public void CloseCall(int durationSeconds = -1) { if (this.currentCall == null) { throw new ApplicationException("No call to close!"); } if (durationSeconds < 0) { this.currentCall.EndCall(); // Will calculate the duration by the system clock } else { this.currentCall.EndCall(durationSeconds); } Call newCall = new Call(this.currentCall); // Copy the current call this.callHistory.Add(newCall); // ... and add it to the call history this.currentCall = null; // ... release the current call }
public void RemoveCall(Call call) { this.CallHistory.Remove(call); }
public void Remove(Call call) { this.performedCalls.Remove(call); }
public void Add(Call call) { performedCalls.Add(call); }
public void AddCall(Call newCall) { this.CallHistory.Add(newCall); }
public void AddCall(Call call) { this.CallHistoryAdder = call; }
public Call AddCall(Call call) { this.callHistory.Add(call); return call; }
public void AddCallToHistory(int year, int month, int day, int hour, int minute, string dialledNumber, int duration) { DateTime date = new DateTime(year, month, day, hour, minute, 0); Call call = new Call(date, dialledNumber, duration); this.callHistory.Add(call); }
/// <summary> /// Opens a new call - creates a new Call object with the dialed number and adds it to the call list. /// </summary> /// <param name="phoneNum">The dialed number</param> public void OpenCall(string phoneNum) { if (this.currentCall != null) { throw new ApplicationException("You can't open a new call before you close the old one!"); } this.currentCall = new Call(phoneNum); }
// Methods public void AddCalls(Call call) { this.HistoryCall.Add(call); }
public void AddCalltoHistory(Call newCall) { if (newCall == null) { throw new ArgumentNullException(@"""null"" calls are not allowed!"); } this.callHistory.Add(newCall); }
public void AddCall(Call call) { this.calls.Add(call); }
public void DeleteCall(Call call) { int index = callHistory.IndexOf(call); if (index != -1) { callHistory.RemoveAt(index); } }
public void DeleteCall(Call call) { this.calls.Remove(call); }
public void DeleteCalls(Call data) { callHistory.Remove(data); }
public void DeleteCall(Call call) { this.callHistory.Remove(call); }
//=== Problem 10 ==> Add methods in the `GSM` class for adding and deleting calls from the calls history. Add a method to clear the call history. public void AddCall(Call call) { CallHistory.Add(call); }
public void AddCall(Call call) { this.callHistory.Add(call); }
public void AddCalls(Call data) { callHistory.Add(data); }