public static void CallHistoryTest()
        {
            const decimal pricePerMinute = 0.37M;

            GSM myGSM = new GSM("123", "test");
            Call call1 = new Call(DateTime.Parse("21.02.2015 15:20:23"), 632, "0889235363");
            Call call2 = new Call(DateTime.Parse("22.02.2015 01:10:23"), 254, "0887775363");
            Call call3 = new Call(DateTime.Parse("23.02.2015 18:20:23"), 954, "0878787800");

            myGSM.AddCalls(call1);
            myGSM.AddCalls(call2);
            myGSM.AddCalls(call3);

            for (int i = 0; i < myGSM.CallHistory.Count; i++)
            {
                Console.WriteLine(myGSM.CallHistory[i]);
            }

            Console.WriteLine("Total price of the calls in the history = {0:F2}",
                               myGSM.PriceOfCalls(pricePerMinute));

            Call maxCall = new Call();
            for (int i = 0; i < myGSM.CallHistory.Count; i++)
            {
                if (myGSM.CallHistory[i].Duration > maxCall.Duration)
                {
                    maxCall = myGSM.CallHistory[i];
                }
            }
            myGSM.DeleteCalls(maxCall);
            Console.WriteLine("Total price of the calls w/o max call = {0:F2}",
                               myGSM.PriceOfCalls(pricePerMinute));

            myGSM.ClearCallHistory();

            Console.WriteLine("Number of calls after history clear: {0}", myGSM.CallHistory.Count);
        }
Exemplo n.º 2
0
 public List<Call> RemoveCall(Call call)
 {
     this.CallHistory.Remove(call);
     return this.CallHistory;
 }
Exemplo n.º 3
0
 public void DeleteCalls(Call call)
 {
     this.callHistory.Remove(call);
 }
Exemplo n.º 4
0
 // Problem 10
 public List<Call> AddCall(Call call)
 {
     this.CallHistory.Add(call);
     return this.CallHistory;
 }
Exemplo n.º 5
0
 //Problem 10. Add/Delete calls
 //Add methods in the GSM class for adding and deleting calls from the calls history.
 public void AddCalls(Call call)
 {
     this.callHistory.Add(call);
 }