DeleteLongestCall() public method

public DeleteLongestCall ( ) : void
return void
Exemplo n.º 1
0
    public static void RunTest()
    {
        GSM myPhone = new GSM("HTC Desire", "HTC", 550, "Pesho", new Battery(BatteryType.LiIon), new Display(4, 250000));
        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(5), "0887776987");
        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(8), "0897556644");
        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(15), "0887441100");
        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(23), "0885001122");
        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(4), "0896559988");

        Console.WriteLine(myPhone);
        Console.WriteLine("-----------Call History-----------");
        foreach (Call call in myPhone.CallHistory)
        {
            Console.WriteLine(call);
        }

        Console.WriteLine("Total price of all calls: ${0:F2}", myPhone.TotalCallsCost(0.37));
        myPhone.DeleteLongestCall();
        Console.WriteLine("After the remove of the longest call the total price is: ${0:F2}", myPhone.TotalCallsCost(0.37));
        Console.WriteLine();

        myPhone.ClearHistory();
        Console.WriteLine("-----------Cleared Call History-----------");
        if (myPhone.CallHistory.Count == 0)
        {
            Console.WriteLine("There are no Recorded Calls in the History!");
        }
        else
        {
            foreach (Call call in myPhone.CallHistory)
            {
                Console.WriteLine(call);
            }
        }
    }
        static void Main()
        {
            // Declare gsm
            GSM apple = new GSM("iPhone5s", "Apple");

            // Directly add call, using inner initializer
            apple.AddCall(new Call(DateTime.Now, "0888 887766", 56));
            apple.AddCall(new Call(new DateTime(2014, 1, 5, 13, 43, 16), "0877 997755", 93));

            // Declare variable of type "Call" and add it to call history of gsm
            Call appleCall = new Call(new DateTime(2014, 1, 4, 16, 10, 37), "+359 888 112233", 347);

            apple.AddCall(appleCall);

            // Assign the array with all calls, returned by the propertie "CallHistory"
            Call[] appleCalls = apple.CallHistory;

            // Print all calls
            for (int i = 0; i < appleCalls.Length; i++)
            {
                Console.WriteLine(appleCalls[i]);
            }

            // Print current total price of all calls.
            // Method "ClalcTotalCallsPrice" take one parameter - price per minute
            Console.WriteLine("Total price: {0}", apple.ClalcTotalCallsPrice(0.37M));

            // Delete longets duration call and print again the total cost of all calls
            apple.DeleteLongestCall();
            Console.WriteLine("Total price after remove of longets call: {0}", apple.ClalcTotalCallsPrice(0.37M));

            // Clear entire call history
            apple.ClearCallHistory();
            // Once again get the call history, to see that it is empty
            appleCalls = apple.CallHistory;

            for (int i = 0; i < appleCalls.Length; i++)
            {
                Console.WriteLine(appleCalls[i]);
            }
        }
Exemplo n.º 3
0
    public static void RunTest()
    {
        GSM myPhone = new GSM("HTC Desire", "HTC", 550, "Pesho", new Battery(BatteryType.LiIon), new Display(4, 250000));

        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(5), "0887776987");
        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(8), "0897556644");
        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(15), "0887441100");
        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(23), "0885001122");
        myPhone.AddCall(DateTime.Today, DateTime.Today.AddMinutes(4), "0896559988");

        Console.WriteLine(myPhone);
        Console.WriteLine("-----------Call History-----------");
        foreach (Call call in myPhone.CallHistory)
        {
            Console.WriteLine(call);
        }

        Console.WriteLine("Total price of all calls: ${0:F2}", myPhone.TotalCallsCost(0.37));
        myPhone.DeleteLongestCall();
        Console.WriteLine("After the remove of the longest call the total price is: ${0:F2}", myPhone.TotalCallsCost(0.37));
        Console.WriteLine();

        myPhone.ClearHistory();
        Console.WriteLine("-----------Cleared Call History-----------");
        if (myPhone.CallHistory.Count == 0)
        {
            Console.WriteLine("There are no Recorded Calls in the History!");
        }
        else
        {
            foreach (Call call in myPhone.CallHistory)
            {
                Console.WriteLine(call);
            }
        }
    }