Exemple #1
0
        //Method
        public void TestCallHistory()
        {
            var phone = new GSM("iPhone", "Apple", 1500, "Rosi", new Battery("Sony", 2, 15, BatteryType.NiCd), new Display(5.5, 256));

            phone.AddCall(new Call(new DateTime(2016, 6, 10, 10, 43, 25), "+359 88 6295 197", 30));
            phone.AddCall(new Call(new DateTime(2016, 6, 10, 8, 35, 12), "+359 88 6295 197", 12));
            phone.AddCall(new Call(new DateTime(2016, 6, 10, 5, 55, 11), "+359 88 6295 197", 125));

            Console.WriteLine(phone.CallHistoryInformation());
            Console.WriteLine("Total price: {0:C}", phone.TotalPrice(0.37m));

            phone.RemoveLongestCall();
            Console.WriteLine("Total price: {0:C}", phone.TotalPrice(0.37m));
            phone.ClearCalls();

            Console.WriteLine(phone.CallHistoryInformation());
        }
Exemple #2
0
        static public void Test()
        {
            GSM gsm = new GSM("Lumia 720", "Nokia", 100, "Pesho", 4.3, 16000000, "Nokia", 100, 100, Battery.BatteryType.LiIon);

            gsm.AddCall(DateTime.Now, "+359886554433", 60);
            gsm.AddCall(DateTime.Now, "+359886114433", 6);
            gsm.AddCall(DateTime.Now, "+359886224433", 12);
            gsm.AddCall(DateTime.Now, "+359886111111", 187);
            gsm.AddCall(DateTime.Now, "+359886222222", 786);

            Console.WriteLine("Calls:");

            foreach (var call in gsm.CallHistory)
            {
                Console.WriteLine("{0}, {1}, {2} seconds", call.DateTimeValue, call.Number, call.Duration);
            }

            Console.WriteLine();
            Console.WriteLine("Total price {0}", gsm.CalculateTotalCallsPrice(0.37));

            var index = gsm.CallHistory.Aggregate((i1, i2) => i1.Duration > i2.Duration ? i1 : i2);

            gsm.RemoveCall(index);

            Console.WriteLine("Calls:");

            foreach (var call in gsm.CallHistory)
            {
                Console.WriteLine("{0}, {1}, {2} seconds", call.DateTimeValue, call.Number, call.Duration);
            }

            Console.WriteLine();
            Console.WriteLine("Total price {0}", gsm.CalculateTotalCallsPrice(0.37));

            gsm.ClearCalls();
        }