static void Main(string[] args) { var device = new GSM("Touch Pro 2", "HTC", "Vlado"); Call firstCall = new Call(180); device.AddCall(firstCall); Console.WriteLine(device.CallHystoryPrice()); }
static void Main(string[] args) { //Create an instance of the GSM class. Battery phoneBattery = new Battery("NiCd", 30.6, 5.6); Display phoneDisplay = new Display(5.0, 16000000); GSM phone = new GSM("Galaxy Note", "Samsung", 866, "Goran Bregovic", phoneBattery, phoneDisplay); //Add few calls. DateTime dateAndTime = new DateTime(2013, 3, 5, 11, 59, 59); Call callOne = new Call(dateAndTime, "0888455455", 110); Call callTwo = new Call(dateAndTime, "0899455455", 50); Call callThree = new Call(dateAndTime, "0886455455", 230); phone.AddCall(callOne); phone.AddCall(callTwo); phone.AddCall(callThree); //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. Console.WriteLine(phone.CallHistoryToString); double price = phone.CalculatePrice(0.37); Console.WriteLine("The price for the whole history is {0}", price); //Remove the longest call from the history and calculate the total price again. uint maxDuritation = uint.MinValue; Call callToRemove = new Call(dateAndTime, "0886455455", 0); for (int i = 0; i < phone.CallHistory.Count; i++) { if (phone.CallHistory[i].Duritation > maxDuritation) { maxDuritation = phone.CallHistory[i].Duritation; callToRemove = phone.CallHistory[i]; } } phone.DeleteCall(callToRemove); price = phone.CalculatePrice(0.37); Console.WriteLine("The new price after we removed the longest call is {0}", price); //Finally clear the call history and print it. Console.WriteLine(); Console.WriteLine("Clearing History..."); phone.ClearHistory(); Console.WriteLine("Call History: {0}", phone.CallHistoryToString); }
//Methods (task 10): public void AddCall(DateTime callDateTime, string dialedNumber, uint callDuration) { Call call = new Call(callDateTime, dialedNumber, callDuration); CallHistory.Add(call); }
//add call to CallHistory public void AddCall(string number, int duration, DateTime date, TimeSpan time) { Call call = new Call(number, duration, date, time); CallHistory.Add(call); }
public void DeleteCall(Call call) { for (int i = 0; i < this.callHistory.Count; i++) { if (this.callHistory[i] == call) { this.callHistory.RemoveAt(i); } } }
public void AddCall(Call call) { this.callHistory.Add(call); }
//method to delete a call from the call history public void DeleteCall(Call call) { for (int i = 0; i < this.callHistory.Count; i++) { if (this.callHistory[i].DialedPhoneNumber == call.DialedPhoneNumber && this.callHistory[i].CallDateTime == call.CallDateTime && this.callHistory[i].Duritation == call.Duritation) { this.callHistory.RemoveAt(i); } } }
//methods for callHistory public void AddCallToHist(DateTime dateAndTime, string dialedNumber, int duration) { Call newCall = new Call(dateAndTime, dialedNumber, duration); callHistory.Add(newCall); }
public void AddCall(string phoneNumber, uint duration) { Call newCall = new Call(phoneNumber, duration); this.calls.Add(newCall); }
public void DeleteCall(Call call) { if (call == null) { throw new ArgumentNullException(); } callHistory.Remove(call); }
public void AddCall(Call call) { if (call == null) { throw new ArgumentNullException(); } callHistory.Add(call); }
public void DeleteCallHistory(Call call) { this.CallHistory.Remove(call); }
public void AddCallHistory(Call call) { this.CallHistory.Add(call); }
//Adding, deleting and clearing CallHistory (Task 10.) public void InsertCallInHist(Call callInfo) { this.callHistory.Add(callInfo); }