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());
        }
Example #2
0
        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);
        }
Example #3
0
 //Methods (task 10):
 public void AddCall(DateTime callDateTime, string dialedNumber, uint callDuration)
 {
     Call call = new Call(callDateTime, dialedNumber, callDuration);
     CallHistory.Add(call);
 }
Example #4
0
 //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);
 }
Example #5
0
 public void DeleteCall(Call call)
 {
     for (int i = 0; i < this.callHistory.Count; i++)
     {
         if (this.callHistory[i] == call)
         {
             this.callHistory.RemoveAt(i);
         }
     }
 }
Example #6
0
 public void AddCall(Call call)
 {
     this.callHistory.Add(call);
 }
Example #7
0
 //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);
         }
     }
 }
Example #8
0
File: GSM.cs Project: kicata/OPP
 //methods for callHistory
 public void AddCallToHist(DateTime dateAndTime, string dialedNumber, int duration)
 {
     Call newCall = new Call(dateAndTime, dialedNumber, duration);
     callHistory.Add(newCall);
 }
Example #9
0
 public void AddCall(string phoneNumber, uint duration)
 {
     Call newCall = new Call(phoneNumber, duration);
     this.calls.Add(newCall);
 }
Example #10
0
        public void DeleteCall(Call call)
        {
            if (call == null)
            {
                throw new ArgumentNullException();
            }

            callHistory.Remove(call);
        }
Example #11
0
        public void AddCall(Call call)
        {
            if (call == null)
            {
                throw new ArgumentNullException();
            }

            callHistory.Add(call);
        }
Example #12
0
 public void DeleteCallHistory(Call call)
 {
     this.CallHistory.Remove(call);
 }
Example #13
0
 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);
 }