GSM.DeleteCall C# (CSharp) Method

DeleteCall() public method

public DeleteCall ( int callIndex ) : void
callIndex int
return void
    public void DeleteCall(int callIndex)
    {
        if (callIndex > 0 && (callIndex <= this.callHistory.Count))
        {
            this.callHistory.RemoveAt(callIndex);
        }
        else
        {
            throw new ApplicationException("Call not found");
        }
    }
    public void DeleteLongestCall()

Usage Example

Exemplo n.º 1
0
        public static void GSMCallHistoryStartTest()
        {
            Console.WriteLine("Call history test");
            DrawLine('-');
            var    testGsm          = new GSM("iPhone 18s", "Apple", 1800m, "Batman");
            Random rndCallLengthGen = new Random();
            Random rndNumberGen     = new Random();

            for (int i = 0; i < 10; i++)
            {
                string number       = "+359" + rndNumberGen.Next(82000001, 90000000);
                uint   callDuration = (uint)rndCallLengthGen.Next(8, 361);
                var    call         = new Call(callDuration, number);
                testGsm.AddCall(call);
            }

            PrintCallHistory(testGsm);
            Console.WriteLine("Total calls price: {0:f2}", testGsm.GetCallsPrice(0.37m));
            Call logestCall = testGsm.CallHistory.OrderByDescending(c => c.Duration).FirstOrDefault();

            testGsm.DeleteCall(logestCall);
            Console.WriteLine("Total calls price after deleting the longest call: {0:f2}", testGsm.GetCallsPrice(0.37m));
            testGsm.ClearCallHistory();
            PrintCallHistory(testGsm);
        }
All Usage Examples Of GSM::DeleteCall