public static void CallHistoryTest()
        {
            //creating GSMs
            var iPhone6  = new GSM("Apple", "iPhone 6");
            var galaxyS6 = new GSM("Samsung", "Galaxy S 6");
            var g3       = new GSM("LG", "G3");

            //adding calls on each GSM's call history
            iPhone6.AddCall(new Call("21.05.2015 15:36:12", "+359888456891", 154));
            iPhone6.AddCall(new Call("22.05.2015 18:38:12", "+359878475896", 35));
            iPhone6.AddCall(new Call("25.05.2015 13:34:12", "+359898475126", 75));

            galaxyS6.AddCall(new Call());

            g3.AddCall(new Call("21.07.2015 15:36:12", "+359888476891", 78));
            g3.AddCall(new Call("7.08.2015 10:25:22", "+359876554015", 45));

            //printing call history and total price of calls
            Console.WriteLine(Environment.NewLine + iPhone6.Model);
            Console.WriteLine(iPhone6.CallHistory);
            Console.WriteLine(iPhone6.PriceOfCalls());

            Console.WriteLine(Environment.NewLine + galaxyS6.Model);
            Console.WriteLine(galaxyS6.CallHistory);
            Console.WriteLine(galaxyS6.PriceOfCalls());

            Console.WriteLine(Environment.NewLine + g3.Model);
            Console.WriteLine(g3.CallHistory);
            Console.WriteLine(g3.PriceOfCalls());

            //deleting call with maximal duration and printing call history and total price of calls
            iPhone6.DeleteCall();
            Console.WriteLine(Environment.NewLine + iPhone6.Model);
            Console.WriteLine(iPhone6.CallHistory);
            Console.WriteLine(iPhone6.PriceOfCalls());

            g3.DeleteCall();
            Console.WriteLine(Environment.NewLine + g3.Model);
            Console.WriteLine(g3.CallHistory);
            Console.WriteLine(g3.PriceOfCalls());

            //clearin call histrory
            iPhone6.ClearHistory();
            Console.WriteLine(Environment.NewLine + iPhone6.Model);
            Console.WriteLine(iPhone6.CallHistory);
            Console.WriteLine(iPhone6.PriceOfCalls());

            g3.ClearHistory();
            Console.WriteLine(Environment.NewLine + g3.Model);
            Console.WriteLine(g3.CallHistory);
            Console.WriteLine(g3.PriceOfCalls());
        }
        public static void CallHistoryTest()
        {
            //creating GSMs
            var iPhone6 = new GSM("Apple", "iPhone 6");
            var galaxyS6 = new GSM("Samsung", "Galaxy S 6");
            var g3 = new GSM("LG", "G3");

            //adding calls on each GSM's call history
            iPhone6.AddCall(new Call("21.05.2015 15:36:12", "+359888456891", 154));
            iPhone6.AddCall(new Call("22.05.2015 18:38:12", "+359878475896", 35));
            iPhone6.AddCall(new Call("25.05.2015 13:34:12", "+359898475126", 75));

            galaxyS6.AddCall(new Call());

            g3.AddCall(new Call("21.07.2015 15:36:12", "+359888476891", 78));
            g3.AddCall(new Call("7.08.2015 10:25:22", "+359876554015", 45));

            //printing call history and total price of calls
            Console.WriteLine(Environment.NewLine + iPhone6.Model);
            Console.WriteLine(iPhone6.CallHistory);
            Console.WriteLine(iPhone6.PriceOfCalls());

            Console.WriteLine(Environment.NewLine + galaxyS6.Model);
            Console.WriteLine(galaxyS6.CallHistory);
            Console.WriteLine(galaxyS6.PriceOfCalls());

            Console.WriteLine(Environment.NewLine + g3.Model);
            Console.WriteLine(g3.CallHistory);
            Console.WriteLine(g3.PriceOfCalls());

            //deleting call with maximal duration and printing call history and total price of calls
            iPhone6.DeleteCall();
            Console.WriteLine(Environment.NewLine + iPhone6.Model);
            Console.WriteLine(iPhone6.CallHistory);
            Console.WriteLine(iPhone6.PriceOfCalls());

            g3.DeleteCall();
            Console.WriteLine(Environment.NewLine + g3.Model);
            Console.WriteLine(g3.CallHistory);
            Console.WriteLine(g3.PriceOfCalls());

            //clearin call histrory
            iPhone6.ClearHistory();
            Console.WriteLine(Environment.NewLine + iPhone6.Model);
            Console.WriteLine(iPhone6.CallHistory);
            Console.WriteLine(iPhone6.PriceOfCalls());

            g3.ClearHistory();
            Console.WriteLine(Environment.NewLine + g3.Model);
            Console.WriteLine(g3.CallHistory);
            Console.WriteLine(g3.PriceOfCalls());
        }
        public static void CallTest()
        {
            // Create an instance of the GSM class.

            var newPhone = new GSM("test model", "random manufacturer");

            // Add few calls.

            newPhone.AddCall(DateTime.Now, 500, "0888424124");
            newPhone.AddCall(new DateTime(2016, 12, 31, 23, 58, 59), 1600, "0888444444");
            newPhone.AddCall(new DateTime(2016, 12, 21, 11, 23, 01), 2600, "0888444333");

            // Display the information about the calls.

            PrintCallHistory(newPhone);

            // Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
            // price is set as a constant in GSM class

            var totalPrice = newPhone.CalculateCallsPrice();

            Console.WriteLine("You must pay: {0:F2} leva", totalPrice);

            // Remove the longest call from the history and calculate the total price again.

            int longestCall      = 0;
            int indexLongestCall = 0;

            for (int i = 0; i < newPhone.CallHistory.Count; i++)
            {
                if (newPhone.CallHistory[i].Duration > longestCall)
                {
                    longestCall      = newPhone.CallHistory[i].Duration;
                    indexLongestCall = i;
                }
            }

            newPhone.DeleteCall(indexLongestCall);

            var newPrice = newPhone.CalculateCallsPrice();

            Console.WriteLine("You must pay: {0:F2} leva", newPrice);


            // Finally clear the call history and print it.

            newPhone.ClearHistory();
            PrintCallHistory(newPhone);
        }
Beispiel #4
0
        public void Test()
        {
            Battery bat   = new Battery("1sd34", 500, 100, BatteryType.NiCd);
            Display disp  = new Display();
            GSM     phone = new GSM("6", "IPhone", bat.ToString(), disp.ToString());

            phone.AddCall("12.12.2012", "15:00", "+359 885 635338", 500);
            phone.AddCall("04.04.2004", "12:00", "+359 885 643453", 200);
            phone.AddCall("01.03.2014", "09:00", "+359 884 654634", 100);

            foreach (var item in GSM.CallList)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("Total price of all calls in history: " + phone.CalculateCallPrice(0.37) + "BGN");


            Console.WriteLine("=========================");
            phone.DeleteCall();

            foreach (var item in GSM.CallList)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("Total price of all calls in history: " + phone.CalculateCallPrice(0.37) + "BGN");

            Console.WriteLine("=========================");
            phone.ClearHistory();

            foreach (var item in GSM.CallList)
            {
                Console.WriteLine(item);
            }
        }