public static void GSMCallHistoryTestMethod()
        {
            Console.WriteLine("\n------------------------------------");
            Console.WriteLine("        Call History Test!");
            Console.WriteLine("------------------------------------\n");

            GSM phone = new GSM("Galaxy S 3", "Samsung");

            phone.AddCall(new Call(DateTime.Parse("6/12/2009 07:23:00 AM"), "0888123456") { Duration = 31 });
            phone.AddCall(new Call(DateTime.Parse("10/11/2010 10:44:00 AM"), "0888678910") { Duration = 360 });
            phone.AddCall(new Call(DateTime.Parse("7/05/2012 06:56:00 PM"), "0888111213") { Duration = 600 });

            PrintCalls(phone);

            //Get longest call.
            var maxCall =
                (from call in phone.CallHistory
                 orderby call.Duration descending
                 select call).First();

            //Delete longest call.
            phone.DeleteCall(phone.CallHistory.IndexOf(maxCall));

            PrintCalls(phone);

            //Clear all calls.
            phone.ClearHistory();

            PrintCalls(phone);
        }
        public static void CallHistoryTest()
        {
            //Create an instance of the GSM class.
            GSM myGsm = GSM.IPhone4S;

            //Add few calls.
            Call someCall = new Call(DateTime.Now, 120, "+359888888888");

            myGsm.AddCall(someCall);
            myGsm.AddCall(someCall);
            myGsm.DeleteCall(someCall);
            myGsm.AddCall(someCall);
            myGsm.AddCall(new Call(new DateTime(2013, 2, 10, 21, 14, 29), 1000, "0885088508"));
            myGsm.AddCall(new Call(new DateTime(2013, 1, 20, 11, 11, 11), 1000, "0885088508"));
            myGsm.AddCall(new Call(DateTime.Now, 119, "+359887121314"));

            //Display the information about the calls.
            Console.WriteLine("All calls:");
            myGsm.PrintAllCalls();

            //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
            PrintCallPrice(myGsm);

            //Remove the longest call from the historyand calculate the total price again.
            myGsm.RemoveLongestDurationCall();
            Console.WriteLine("\nAfter remove of longest duration call...");
            PrintCallPrice(myGsm);

            //Finally clear the call history and print it.
            myGsm.ClearCallHistory();
            Console.WriteLine("\nAfter clear...");
            myGsm.PrintAllCalls();
            PrintCallPrice(myGsm);
        }
        static void Main()
        {
            // create test GSM
            string delimiter  = new string('\xA', 3) + new string('-', 35);
            GSM    genericGsm = new GSM("Test model", "Test manufacturer");

            // add calls
            var date1 = new DateTime(2014, 03, 10, 04, 55, 0);
            var date2 = new DateTime(2014, 03, 10, 13, 55, 0);
            var date3 = new DateTime(2014, 03, 10, 18, 55, 0);

            genericGsm.AddCall(new Call(date1, "+359885985678", 90));
            genericGsm.AddCall(new Call(date2, "+359885985678", 120));
            genericGsm.AddCall(new Call(date3, "+359885985678", 70));


            // display calls
            Console.WriteLine("DISPLAY ALL CALLS");
            PrintCallHistory("\nNEXT CALL\n", genericGsm);


            // calculate total price of calls
            Console.WriteLine(delimiter);
            Console.WriteLine("CALCULATE TOTAL BILL");
            Console.WriteLine("Total Bill: {0:0.00}", genericGsm.TotalCallsBill());


            // remove longest call
            Console.WriteLine(delimiter);
            Console.WriteLine("REMOVE LONGEST CALL");
            int maxDuration      = 0;
            int maxDurationIndex = 0;

            for (int i = 0; i < genericGsm.CallHistory.Count; i++)
            {
                if (genericGsm.CallHistory[i].Duration > maxDuration)
                {
                    maxDuration      = genericGsm.CallHistory[i].Duration;
                    maxDurationIndex = i;
                }
            }

            genericGsm.DeleteCall(maxDurationIndex);
            Console.WriteLine("CALCULATE TOTAL BILL");
            Console.WriteLine("Total Bill: {0:0.00}", genericGsm.TotalCallsBill());


            // clear call history and print
            Console.WriteLine(delimiter);
            Console.WriteLine("CLEAR CALL HISTORY AND PRINT");
            genericGsm.ClearCalls();
            PrintCallHistory(delimiter, genericGsm);
        }
        public static void GSMCallHistoryTest()
        {
            GSM testCalls = new GSM("WildFire", "HTC", 150, "Ivan", new Battery(BatteryType.LiIon));

            testCalls.AddCall(new DateTime(2015, 7, 26, 15, 15, 26), "+359889653420", 88);
            testCalls.AddCall(new DateTime(2015, 7, 26, 16, 16, 16), "+359824568420", 64);
            testCalls.AddCall(new DateTime(2015, 7, 26, 15, 31, 59), "+359862487258", 1360);
            testCalls.AddCall(new DateTime(2015, 7, 26, 16, 0, 10), "+359883426864", 366);

            Console.WriteLine("Call history");

            foreach (var item in testCalls.CallHistory)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("Total price for all calls:{0}", testCalls.CallPrice((decimal)0.37));
            Console.WriteLine();
            Console.WriteLine("After removing the longest call...");

            int longestIndex = 0;
            int time = 0;

            for (int i = 0; i < testCalls.CallHistory.Count; i++)
            {
                if (testCalls.CallHistory[i].Time > time)
                {
                    time = testCalls.CallHistory[i].Time;
                    longestIndex = i;
                }
            }

            testCalls.DeleteCall(longestIndex);

            foreach (var item in testCalls.CallHistory)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("Total price of call history:{0}", testCalls.CallPrice(0.37m));
            Console.WriteLine("Deleting the call history...");
            testCalls.CallHistoryClear();
            Console.WriteLine();
            Console.WriteLine("Call history:");

            foreach (var item in testCalls.CallHistory)
            {
                Console.WriteLine(item);
            }
        }
        static void Main()
        {
            // create test GSM
            string delimiter = new string('\xA', 3) + new string('-', 35);
            GSM genericGsm = new GSM("Test model", "Test manufacturer");

            // add calls
            var date1 = new DateTime(2014, 03, 10, 04, 55, 0);
            var date2 = new DateTime(2014, 03, 10, 13, 55, 0);
            var date3 = new DateTime(2014, 03, 10, 18, 55, 0);
            genericGsm.AddCall(new Call(date1, "+359885985678", 90));
            genericGsm.AddCall(new Call(date2, "+359885985678", 120));
            genericGsm.AddCall(new Call(date3, "+359885985678", 70));

            // display calls
            Console.WriteLine("DISPLAY ALL CALLS");
            PrintCallHistory("\nNEXT CALL\n", genericGsm);

            // calculate total price of calls
            Console.WriteLine(delimiter);
            Console.WriteLine("CALCULATE TOTAL BILL");
            Console.WriteLine("Total Bill: {0:0.00}", genericGsm.TotalCallsBill());

            // remove longest call
            Console.WriteLine(delimiter);
            Console.WriteLine("REMOVE LONGEST CALL");
            int maxDuration = 0;
            int maxDurationIndex = 0;
            for (int i = 0; i < genericGsm.CallHistory.Count; i++)
            {
                if (genericGsm.CallHistory[i].Duration > maxDuration)
                {
                    maxDuration = genericGsm.CallHistory[i].Duration;
                    maxDurationIndex = i;
                }
            }

            genericGsm.DeleteCall(maxDurationIndex);
            Console.WriteLine("CALCULATE TOTAL BILL");
            Console.WriteLine("Total Bill: {0:0.00}", genericGsm.TotalCallsBill());

            // clear call history and print
            Console.WriteLine(delimiter);
            Console.WriteLine("CLEAR CALL HISTORY AND PRINT");
            genericGsm.ClearCalls();
            PrintCallHistory(delimiter, genericGsm);
        }
Example #6
0
        static void Main()
        {
            //create a test instance & add 3 calls
            var gsmTest = new GSM("nokia", "test model");

            gsmTest.AddCall(new Call(new DateTime(2015, 12, 31, 10, 00, 00), "0888123456", 61));
            gsmTest.AddCall(new Call(new DateTime(2016, 12, 31, 10, 15, 00), "0888666555", 333));
            gsmTest.AddCall(new Call(new DateTime(2017, 01, 01, 00, 00, 01), "0888123456", 60));


            //test call price calculations
            Console.WriteLine("Test call price calculation method\r\n==========================================");
            Console.WriteLine("Total Calls Count: {0}", gsmTest.CallHistory.Count);
            Console.WriteLine("Total Price: {0: 0.00}", gsmTest.CallPrice(0.37M));
            Console.WriteLine();

            //print initial state of the instance
            Console.WriteLine("Initial state of the gsmTest object\r\n==========================================\r\n{0}", gsmTest);

            //delete the longest call
            int indexLongestCall = -1;
            int maxSeconds       = 0;

            foreach (var call in gsmTest.CallHistory)
            {
                if (call.Duration > maxSeconds)
                {
                    maxSeconds = (int)call.Duration;
                    indexLongestCall++;
                }
            }
            gsmTest.DeleteCall(indexLongestCall);

            //print price without longest call
            Console.WriteLine("\r\nPrice calculation without the longest call\r\n==========================================");
            Console.WriteLine("Total Calls Count: {0}", gsmTest.CallHistory.Count);
            Console.WriteLine("Total Price: {0: 0.00}\r\n", gsmTest.CallPrice(0.37M));
            Console.WriteLine("gsmTest object without the longest call\r\n==========================================\r\n{0}", gsmTest);

            //print the final state of the instance

            //clear the history
            gsmTest.ClearHistory();

            Console.WriteLine("gsmTest object with cleared history\r\n==========================================\r\n{0}", gsmTest);
        }
        public static void CreateCallHistory()
        {
            GSM testgsm = new GSM();

            Call callOne   = new Call(new DateTime(2015, 02, 03), new DateTime(2015, 02, 03, 14, 05, 25), "private number", 23);
            Call callTwo   = new Call(new DateTime(2015, 02, 03), new DateTime(2015, 02, 03, 17, 14, 38), "private number", 701);
            Call callThree = new Call(new DateTime(2015, 02, 04), new DateTime(2015, 02, 03, 10, 02, 45), "private number", 411);

            //Add few calls
            Console.WriteLine("Added few calls");
            testgsm.CallHistory.Add(callOne);
            testgsm.CallHistory.Add(callTwo);
            testgsm.CallHistory.Add(callThree);



            Console.WriteLine("Info" + new string('-', 40));
            Console.WriteLine("Initial number of calls: {0}", testgsm.CallHistory.Count);
            Console.WriteLine("Price of the calls: " + testgsm.CalculateCallPrice());
            Console.WriteLine("Longest call: {0}", testgsm.FindLongestCall().Duration);

            Console.WriteLine("\nAdd a new call");
            testgsm.AddCall(new Call(new DateTime(2015, 02, 04), new DateTime(2015, 02, 03, 10, 33, 45), "private number", 806));
            Console.WriteLine("Info" + new string('-', 40));
            Console.WriteLine("Number of calls: {0}", testgsm.CallHistory.Count);
            Console.WriteLine("Price of the calls: " + testgsm.CalculateCallPrice());
            Console.WriteLine("Longest call: {0}", testgsm.FindLongestCall().Duration);

            //Delete longest call
            testgsm.DeleteCall(testgsm.CallHistory.IndexOf(testgsm.FindLongestCall()));
            Console.WriteLine("\nDelete longest call");
            Console.WriteLine("Info" + new string('-', 40));
            Console.WriteLine("Number of calls: {0}", testgsm.CallHistory.Count);
            Console.WriteLine("Price of the calls: " + testgsm.CalculateCallPrice());
            Console.WriteLine("Longest call: {0}", testgsm.FindLongestCall().Duration);

            Console.WriteLine("\nDelete all call history");
            testgsm.DeleteAllHistory();
            Console.WriteLine("Info" + new string('-', 40));
            Console.WriteLine("Number of calls: {0}", testgsm.CallHistory.Count);


            Console.WriteLine(testgsm.CallHistory.Count);
        }
Example #8
0
        private static void GSMCallHistoryTest()
        {
            GSM testGsm = new GSM("Privileg", "MyFriend");

            testGsm.AddCall(DateTime.Now, "+359895258796", 48);
            testGsm.AddCall(DateTime.Now, "+359872456789", 899);
            testGsm.AddCall(DateTime.Now, "+359973679023", 68);
            testGsm.AddCall(DateTime.Now, "+359111222333", 25);
            testGsm.AddCall(DateTime.Now, "+359444555666", 348);

            testGsm.ShowCallHistory();

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

            testGsm.DeleteCall(1);
            Console.WriteLine("Removed the longest call!");

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

            testGsm.ClearCallHistory();
            Console.WriteLine("Cleared call history!");
            testGsm.ShowCallHistory();
        }
Example #9
0
        private static void GSMCallHistoryTest()
        {
            GSM testGsm = new GSM("Nokia", "TelerikCorp");

            testGsm.AddCall("0888888881", 20);
            testGsm.AddCall("0888888882", 60);
            testGsm.AddCall("0888888883", 10);
            testGsm.AddCall("0888888884", 30);
            testGsm.AddCall("+359888888885", 250);

            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();
        }