Пример #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();
        }
Пример #3
0
        public static void CallHistoryTest()
        {
            GSM testGSM = GSM.IPhone4s;

            testGSM.AddCall("0999-999-999", 2.3);
            testGSM.AddCall("0888-999-999", 12.4);
            testGSM.AddCall("0777-999-999", 4.34);
            testGSM.AddCall("0666-999-999", 8.2);
            testGSM.AddCall("0555-999-999", 11.2);
            Console.WriteLine("-------Showing added calls--------");
            testGSM.ShowCallHistory();

            Console.WriteLine("------Calculating total price for calls------");
            double totalCallPrice = testGSM.CalculateCallsTotalPrice();

            Console.WriteLine("{0:C}", totalCallPrice);

            Console.WriteLine("----Removing longest call and recalculating-----");
            testGSM.RemoveLongestCallEntry();
            testGSM.ShowCallHistory();
            totalCallPrice = testGSM.CalculateCallsTotalPrice();
            Console.WriteLine("{0:C}", totalCallPrice);

            Console.WriteLine("----Clearing call history-----");
            testGSM.ClearCallHistory();
            testGSM.ShowCallHistory();
        }
 //add few calls in the phone
 public GSMCallHistoryTest()
 {
     phone = new GSM("Diamond", "HTC", "Pesho", 700.0, battery1, display1);
     phone.AddCall("0888123456", 133, DateTime.Parse("22.02.2013"),TimeSpan.Parse("15:16"));
     phone.AddCall("0888000001", 15, DateTime.Parse("20.02.2013"), TimeSpan.Parse("10:20"));
     phone.AddCall("0888000002", 62, DateTime.Parse("19.02.2013"), TimeSpan.Parse("22:30"));
 }
Пример #5
0
        static void Main(string[] args)
        {
            var device = new GSM("Touch Pro 2", "HTC", "Vlado");

            Call firstCall = new Call(180);
            device.AddCall(firstCall);

            Console.WriteLine(device.CallHystoryPrice());
        }
        // 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();
        }
Пример #7
0
        public static void HistoryTest()
        {
            GSM one = new GSM("mod", "manu");

            Console.WriteLine(one.CallHistory.Count);

            Call someCall = new Call("135", 100);
            Call two      = new Call("6541651", 102);

            one.AddCall(someCall);
            Console.WriteLine(one.CallHistory.Count);
            one.AddCall(two);
            Console.WriteLine(one.CallHistory.Count);

            Console.WriteLine(one.CalcPriceOfCalls());


            Console.WriteLine(one.ToString());

            one.RemoveLongestCall();

            Console.WriteLine(one.ToString());
        }
        public void CallHistoryTest()
        {
            phone.AddCall(call1);
            phone.AddCall(call2);
            phone.AddCall(call3);

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

            Console.WriteLine("Total price of calls: {0:0.00}", phone.CalculatePrice(0.37m)); Console.WriteLine();

            phone.RemoveCall(2);
            Console.WriteLine("Total price without longest call: {0:0.00}", phone.CalculatePrice(0.37m)); Console.WriteLine();

            phone.ClearHistory();
            foreach (var call in phone.CallHistory)
            {
                Console.WriteLine(call);
            }
        }
Пример #9
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();
        }
Пример #10
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();
        }
Пример #11
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);
        }