Ejemplo n.º 1
0
        public static void CallHistoryTestPrint()
        {
            var myPhone = new Gsm(
                "THL", "China", "Niki", 200.5M, new Battery(BatteryType.Li_Ion, 60, 20), new Display(5.5M, 16000000));

            Console.WriteLine(myPhone);

            myPhone.AddCall(DateTime.Now, 0885998877, 65);
            myPhone.AddCall(DateTime.UtcNow, 0885665544, 98);
            myPhone.AddCall(DateTime.Now, 0885552277, 158);
            myPhone.AddCall(DateTime.Now, 0885996857, 112);
            myPhone.AddCall(DateTime.Now, 0885995827, 87);

            Console.WriteLine(myPhone.CallHistory);

            var priceInfo = new StringBuilder();

            priceInfo.AppendFormat("Total price: {0:C2}", myPhone.CallPrice());

            myPhone.RemoveLongestCall();

            priceInfo.AppendFormat(Environment.NewLine);
            priceInfo.AppendFormat("Longest Call removed");
            priceInfo.AppendFormat(Environment.NewLine);
            priceInfo.AppendFormat("Total price: {0:C2}", myPhone.CallPrice());

            myPhone.ClearCallHistory();

            Console.WriteLine(priceInfo);
            Console.WriteLine(myPhone.CallHistory);
        }
Ejemplo n.º 2
0
        public static void CallHistoryTest()
        {
            Gsm test2 = new Gsm("3310", "Nokia", 50.5M, "Gosho", new Battery("12345EN", 50, 30, BatteryType.Nickel_Cadmium), new Display(2.2, 16));

            test2.AddCall("13.03.2010", "16:10", "15429580239", 582);
            test2.AddCall("12.04.2011", "11:22", "31235513132", 1318);
            test2.AddCall("09.11.2012", "20:55", "65426527474", 310);

            Console.WriteLine(test2.CallHistory);
            Console.WriteLine(test2.GetTotalPrice());

            test2.DeleteLongestCall();
            Console.WriteLine(test2.GetTotalPrice());
            test2.DeleteAllCalls();
            Console.WriteLine(test2.GetTotalPrice());
        }
Ejemplo n.º 3
0
        //Problem 12
        public static void StartTest()
        {
            var gsm = new Gsm("Samsung", "S300");

            gsm.AddCall("6/15/2009 1:45 PM", 50, "088889880");
            gsm.AddCall("7/16/2010 2:45 PM", 60, "088889861");
            gsm.AddCall("8/17/2011 3:45 PM", 70, "088889862");
            gsm.AddCall("9/18/2012 4:45 PM", 80, "088889863");
            gsm.AddCall("10/19/2014 6:45 PM", 1500, "088889865");
            gsm.AddCall("10/19/2013 5:45 PM", 100, "088889864");

            var longestCall = gsm.CallHistory[0];

            Console.WriteLine("Starting call history test:\n");
            foreach (var call in gsm.CallHistory)
            {
                Console.WriteLine("Call date: " + call.DateTime);
                Console.WriteLine("Call duration in seconds: " + call.DurationInSeconds);
                Console.WriteLine("Call to: " + call.DialedNumber + "\n");

                if (longestCall.DurationInSeconds < call.DurationInSeconds)
                {
                    longestCall = call;
                }
            }
            Console.WriteLine("Total price of calls before removing longest: {0:F2}\n",
                              +gsm.GetTotalPriceOfCalls(PricePerMin));
            Console.WriteLine("Deleting longest call. Starting test:\n");
            gsm.DeleteCall(longestCall);

            foreach (var call in gsm.CallHistory)
            {
                Console.WriteLine("Call date: " + call.DateTime);
                Console.WriteLine("Call duration in seconds: " + call.DurationInSeconds);
                Console.WriteLine("Call to: " + call.DialedNumber + "\n");
            }
            Console.WriteLine("Total price of calls after removing longest: {0:F2}\n",
                              +gsm.GetTotalPriceOfCalls(PricePerMin));
        }