Пример #1
0
        public static void Start()
        {
            //Create an instance of the GSM class.
            var myPhone = new GSM("GalaxyS6", "Samsung");

            //Add few calls.
            myPhone.AddCall(new Call(new DateTime(2015, 3, 5, 9, 30, 10), "0883448036", 140));
            myPhone.AddCall(new Call(new DateTime(2015, 3, 4, 10, 12, 53), "0883428135", 230));
            myPhone.AddCall(new Call(new DateTime(2015, 3, 12, 19, 3, 32), "0883451438", 423));

            //Print call information
            myPhone.PrintCallHistory();
            Console.WriteLine();

            //Print the total price of the calls in the history for 0.37 per minute
            Console.WriteLine("Total calls price: ${0:0.##}", myPhone.GetCallsTotalPrise(0.37M));

            //Remove the longest call from the history and calculate the total price again
            var longestCall = myPhone.CallHistory.OrderByDescending(x => x.Duration).First();
            myPhone.DeleteCall(longestCall);
            Console.WriteLine("Longest call removed!");
            Console.WriteLine("Total calls price: ${0:0.##}", myPhone.GetCallsTotalPrise(0.37M));
            Console.WriteLine();
            myPhone.PrintCallHistory();

            //Finally clear the call history and print it.
            myPhone.ClearHistory();
            Console.WriteLine("History cleared!");
            myPhone.PrintCallHistory();
        }
        public void GSMCallHistoryTesting()
        {
            // Create an instance of the GSM class.
            GSM testGsm = new GSM("Nokia", "TelerikCorp");

            // Add few calls.
            testGsm.AddCall("9873432142", 53);
            testGsm.AddCall("9811433144", 123);
            testGsm.AddCall("9872411149", 41);

            // Display the information about the calls.
            testGsm.ShowCallHistory();

            // Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
            Console.WriteLine("Total call price: " + testGsm.TotalCallPrice());

            //  Remove the longest call from the history and calculate the total price again.
            testGsm.DeleteCall(2);
            Console.WriteLine("Removed Longest call!");
            Console.WriteLine("Total call price: " + testGsm.TotalCallPrice());

            //// Clear the call history and print it.
            //testGsm.ClearCallHistory();
            //Console.WriteLine("Cleared call history!");
            //testGsm.ShowCallHistory();
        }
        // The following method is executed in the Main() method which is located in the TestExecution class
        public static void CallHistoryTest()
        {
            GSM myGSM = new GSM("Galaxy Note III", "Samsung");  // Initialize a new phone

            myGSM.AddCall(DateTime.Now.AddSeconds(8432), "0888123456", 36);         // Stuff it's call history with entries
            myGSM.AddCall(DateTime.Now.AddSeconds(12415), "+359888123456", 511);
            myGSM.AddCall(DateTime.Now.AddSeconds(22425), "0877123456", 14);
            myGSM.AddCall(DateTime.Now.AddSeconds(29434), "+359888123456", 643);
            myGSM.AddCall(DateTime.Now.AddSeconds(42213), "0899123456", 186);
            myGSM.AddCall(DateTime.Now.AddSeconds(52411), "+359888123456", 152);

            myGSM.DisplayCallHistory(); // Display the call history
            Console.WriteLine();
            Console.WriteLine("Price: {0:f2}", myGSM.TotalPrice(.37));  // Display the price for all the entries
            Console.WriteLine();

            myGSM.DeleteCall(FindIndexOfLongestCall(myGSM));    // Remove the entry at the index where the longest call is kept

            myGSM.DisplayCallHistory();
            Console.WriteLine();
            Console.WriteLine("Price: {0:f2}", myGSM.TotalPrice(.37));  // Display the price for the entries that remain
            Console.WriteLine();

            myGSM.ClearHistory();       // Clear the history

            myGSM.DisplayCallHistory();
            Console.WriteLine();
            Console.WriteLine("Price: {0:f2}", myGSM.TotalPrice(.37));
            Console.WriteLine();
        }
Пример #4
0
        static void Main()
        {
            var gsm = new GSM("Samsung", "S7 Edge+", 1200.0m, "Stamat", new Battery {
                Model = "G1567", HoursIdle = 78, HoursTalk = 20,
            }, new Display {
                Size = 5.4, NumberOfColors = 64000000
            }, BatteryType.NiCd);

            gsm.CallHistory.Add(new Call()
            {
                Duration = 1000, DialedPhone = "+359********9"
            });

            for (int i = 0; i < 10; i++)
            {
                gsm.AddCall(new Call()
                {
                    DialedPhone = "+359********" + i,
                    Duration    = (uint)(i + 1) * 120
                });
            }

            var maxCall = new Call();

            foreach (Call call in gsm.CallHistory)
            {
                Console.WriteLine(call);
                if (maxCall.Duration < call.Duration)
                {
                    maxCall = call;
                }
            }

            Console.WriteLine("Total calls: {0}", gsm.CalculateTotalCost(0.37m));
            gsm.DeleteCall(maxCall);
            Console.WriteLine("Total calls without Longest Call: {0}", gsm.CalculateTotalCost(0.37m));

            Console.WriteLine(gsm.ToString());

            Console.WriteLine(GSM.Iphone4S);
        }
Пример #5
0
        private static void GSMCallHistoryTest()
        {
            GSM testGsm = new GSM("Nokia", "TelerikCorp");

            testGsm.AddCall("+359873432142", 53);
            testGsm.AddCall("+359811432142", 123);
            testGsm.AddCall("+359872412142", 41);
            testGsm.AddCall("+359833332142", 72);
            testGsm.AddCall("+359614432142", 231);

            testGsm.ShowCallHistory();

            Console.WriteLine("Total call price: " + testGsm.TotalCallPrice());

            testGsm.DeleteCall(5);
            Console.WriteLine("Removed Longest call!");

            Console.WriteLine("Total call price: " + testGsm.TotalCallPrice());

            testGsm.ClearCallHistory();
            Console.WriteLine("Cleared call history!");
            testGsm.ShowCallHistory();
        }
Пример #6
0
        public static void TestCallHistory()
        {
            Call call0 = new Call("31.3.2015 9:08:33", "00359 888888", 60);
            Call call1 = new Call("01.4.2015 22:19:04", "+44 123123", 578);
            Call call2 = new Call("02.05.2016 02:16:00", "02 967 2323", 134);

            gsm.AddCall(call0);
            gsm.AddCall(call1);
            gsm.AddCall(call2);

            gsm.ShowCallHistory();

            decimal pricePerMinute = 0.37m;

            Console.WriteLine("Total price: {0:C}", gsm.CalculateTotalPriceOfCalls(pricePerMinute));

            gsm.DeleteCall(1);

            Console.WriteLine("Total price: {0:C}", gsm.CalculateTotalPriceOfCalls(pricePerMinute));

            gsm.ClearCallHistory();

            gsm.ShowCallHistory();
        }