예제 #1
0
        static void Main()
        {
            MobilePhone[] testPhones = new MobilePhone[3];

            for (int i = 0; i < 3; i++)
            {
                testPhones[i] = new MobilePhone(
                    model[randomPick.Next(0, model.Length)],
                    brand[randomPick.Next(0, brand.Length)],
                    price[randomPick.Next(0, price.Length)],
                    owner[randomPick.Next(0, owner.Length)],
                    batteries[randomPick.Next(0, batteries.Length)],
                    displays[randomPick.Next(0, displays.Length)]);
                Console.WriteLine(testPhones[i]);
            }

            var testIphone4S = MobilePhone.iPhone4S;

            Console.WriteLine(testIphone4S);

            MobilePhone testPhone = MobilePhone.iPhone4S;

            testPhone.AddCall(new Calls("882131411", randomPick.Next(1, 1000)));
            testPhone.AddCall(new Calls("877717222", randomPick.Next(1, 1000)));
            testPhone.AddCall(new Calls("886687341", randomPick.Next(1, 1000)));
            testPhone.AddCall(new Calls("894141411", randomPick.Next(1, 1000)));
            testPhone.AddCall(new Calls("893783343", randomPick.Next(1, 1000)));

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

            Console.WriteLine("The total cost of all conversations is {0:C}\n", testPhone.PriceOfCall());
            Calls longest = testPhone.CallHistory.OrderByDescending(x => x.CallDuration).FirstOrDefault();

            testPhone.RemoveCall(longest);
            Console.WriteLine("The total cost after remove longest conversation is: {0:C}\n"
                              , testPhone.PriceOfCall());

            testPhone.ClearCallHistory();
            Console.WriteLine("Total number of Calls in Call History {0}\n", testPhone.CallHistory.Count);
        }
        static void Main()
        {
            MobilePhone[] testPhones = new MobilePhone[3];

            for (int i = 0; i < 3; i++)
            {
                testPhones[i] = new MobilePhone(
                    model[randomPick.Next(0, model.Length)],
                    brand[randomPick.Next(0, brand.Length)],
                    price[randomPick.Next(0, price.Length)],
                    owner[randomPick.Next(0, owner.Length)],
                    batteries[randomPick.Next(0, batteries.Length)],
                    displays[randomPick.Next(0, displays.Length)]);
                Console.WriteLine(testPhones[i]);
            }

            var testIphone4S = MobilePhone.iPhone4S;
            Console.WriteLine(testIphone4S);

            MobilePhone testPhone = MobilePhone.iPhone4S;

            testPhone.AddCall(new Calls("882131411", randomPick.Next(1, 1000)));
            testPhone.AddCall(new Calls("877717222", randomPick.Next(1, 1000)));
            testPhone.AddCall(new Calls("886687341", randomPick.Next(1, 1000)));
            testPhone.AddCall(new Calls("894141411", randomPick.Next(1, 1000)));
            testPhone.AddCall(new Calls("893783343", randomPick.Next(1, 1000)));

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

            Console.WriteLine("The total cost of all conversations is {0:C}\n", testPhone.PriceOfCall());
            Calls longest = testPhone.CallHistory.OrderByDescending(x => x.CallDuration).FirstOrDefault();
            testPhone.RemoveCall(longest);
            Console.WriteLine("The total cost after remove longest conversation is: {0:C}\n"
                , testPhone.PriceOfCall());

            testPhone.ClearCallHistory();
            Console.WriteLine("Total number of Calls in Call History {0}\n", testPhone.CallHistory.Count);
        }