Exemple #1
0
        public void RunTests()
        {
            MobilePhone myMobilePhone = new MobilePhone("Moto G", "Motorola", 200, "Me");

            myMobilePhone.AddCall(new Call(new DateTime(2015, 3, 13), new DateTime(2027, 3, 13, 21, 03, 45), "0888123456", 3623));
            myMobilePhone.AddCall(new Call(new DateTime(2015, 3, 14), new DateTime(2027, 3, 14, 3, 56, 23), "0888123456", 263));
            myMobilePhone.AddCall(new Call(new DateTime(2015, 3, 15), new DateTime(2027, 3, 15, 14, 27, 13), "0888123456", 23));
            myMobilePhone.AddCall(new Call(new DateTime(2015, 3, 16), new DateTime(2027, 3, 16, 19, 55, 23), "0888123456", 13472));

            foreach (var call in myMobilePhone.CallHistory)
            {
                Console.WriteLine(call.ToString());
            }

            Console.WriteLine("\nTotal price of calls: {0:C2}", myMobilePhone.CalculateCallsPrice(0.37));

            myMobilePhone.DeleteCall(myMobilePhone.CallHistory.OrderByDescending(c => c.Duration).First());

            Console.WriteLine("\nTotal price of calls: {0:C2}", myMobilePhone.CalculateCallsPrice(0.37));

            myMobilePhone.ClearHistory();

            foreach (var call in myMobilePhone.CallHistory)
            {
                Console.WriteLine(call.ToString());
            }
        }
Exemple #2
0
        public void RunTests()
        {
            MobilePhone myMobilePhone    = new MobilePhone("Moto G", "Motorola", 200, "Me");
            MobilePhone yourMobilePhone  = new MobilePhone("M9", "HTC", 1000, "Someone else", new Battery("HTC Battery", 109, 400, BatteryType.LiIon));
            MobilePhone herMobilePhone   = new MobilePhone("Lumia", "Microsoft", 500, "Jane Doe", new Battery("Microsoft Battery", 87, 234, BatteryType.NiMH), new Display(10));
            MobilePhone hisMobilePhone   = new MobilePhone("One", "OnePlus", 300, "i don't care in chinese", new Battery("Some Battery", 123, 265, BatteryType.LiPoly), new Display(13, 16000000));
            MobilePhone theirMobilePhone = new MobilePhone("Note 2", "Samsung", 100, "some asshole");

            MobilePhone[] phones = { myMobilePhone, yourMobilePhone, herMobilePhone, hisMobilePhone, theirMobilePhone };

            foreach (var phone in phones)
            {
                Console.WriteLine(phone.ToString());
                Console.WriteLine(new string('-', 35));
            }

            Console.WriteLine(MobilePhone.IPhone7.ToString());
        }