public static void TestingCallHistory()
        {
            Console.WriteLine("----Problem 8, 9, 10----");

            var gsm = new GSM("HH", "Nokia", 199, "Az", new Battery("JJY", BatteryType.LiIon, 7, 10), new Display("JHYUIS", 24));

            gsm.AddCall(new Call(DateTime.Now, "+35976567889", 30));
            gsm.AddCall(new Call(DateTime.Now.AddHours(-7), "+359896787865", 539));
            gsm.AddCall(new Call(DateTime.Now.AddHours(-7), "+359896733365", 223));

            // Print info about the calls
            Console.WriteLine("Calls info");
            foreach (var call in gsm.CallHistory)
            {
                Console.WriteLine(call.ToString());
            }

            // Calculate the price for total call duration
            var priceForPaying = GSM.CalculateTotalAmountForCalls(gsm.CallHistory, 0.37);

            Console.WriteLine($"\nPrice for paying: {priceForPaying} $");

            // Find the longest call by using linq extensions
            Call longestCall = gsm.CallHistory.OrderByDescending(x => x.Duration).First();

            gsm.CallHistory.Remove(longestCall);

            var priceForPayingAfterRemovingTheLongest = GSM.CalculateTotalAmountForCalls(gsm.CallHistory, 0.37);

            Console.WriteLine($"Price for paying after removing the longest call: {priceForPayingAfterRemovingTheLongest} $");

            gsm.ClearCallHistory();
        }
예제 #2
0
        public static void TestingGsmClass()
        {
            var collectionOfGSM = new List <GSM>();

            var htc = new GSM(
                "One",
                "HTC",
                1555,
                "Bai Ivan",
                new Battery(
                    "OOPG2",
                    BatteryType.NiCd,
                    10,
                    2000),
                new Display(
                    "AO111C",
                    10));

            var samsung = new GSM(
                "Galaxy S7",
                "Samsung",
                2000,
                "James",
                new Battery(
                    "OUDG3",
                    BatteryType.LiIon,
                    2,
                    3000),
                new Display(
                    "HtRy4",
                    22));

            var huawei = new GSM(
                "P9",
                "Huawei",
                3000,
                "Mike",
                new Battery(
                    "FFG3",
                    BatteryType.NiMH,
                    1,
                    3989),
                new Display(
                    "TG6&",
                    32));

            collectionOfGSM.Add(htc);
            collectionOfGSM.Add(samsung);
            collectionOfGSM.Add(huawei);

            foreach (var gsm in collectionOfGSM)
            {
                Console.Write(gsm.ToString());
            }

            Console.WriteLine(GSM.IPhone4S.ToString());
        }