﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _01.Define_classes
{
    public class CallHistoryTest
    {
        public static void Main()
        {
            var myPhone = new GSM("3310", "Nokia");

            ////Create randomly 3 phone calls. For more realistic, but slower simulation, multiply duration *1000;

            for (int i = 0; i < 3; i++)
            {
                myPhone.AddCallsToHistory(new Call());
                System.Threading.Thread.Sleep(new Call().Duration);
            }

            Console.WriteLine("My phone is:");
            Console.WriteLine(myPhone);
            myPhone.DisplayCallHistory();
            myPhone.CalculatePriceTotalCalls(0.37); // given 0.37 euro price per minute

            ////Removing longest call and calculating total price again
            Call longestCall = new Call();
            var longestDuration = 0;
            foreach (var call in myPhone.CallHistory)
            {
                if (call.Duration > longestDuration)
                {
                    longestCall = call;
                    longestDuration = call.Duration;
                }
            }

            myPhone.DeleteCallsFromHistory(longestCall);
            Console.WriteLine();
            Console.WriteLine($"---CALL HISTORY AFTER DELETING LONGEST, {longestDuration} SECS LONG CALL ---");
            Console.WriteLine();
            myPhone.DisplayCallHistory();

            ////Calculate price again
            myPhone.CalculatePriceTotalCalls(0.37);
            Console.WriteLine("Clearing call history");
            myPhone.ClearCallHistory();
            myPhone.DisplayCallHistory();
            Console.WriteLine("Done");
            Console.WriteLine();

            // Console.WriteLine("---PRINTING GSM INSTANCES---");
            // Console.WriteLine();
            // GSMTest.TestGsm();
        }
    }
}
