public static void TestCallHistory()
        {
            GSM myGSM = new GSM("Xperia S", "Sony", 700, "Slim Shady",
                new Battery(BatteryType.LiIon, "1750", 48, 24), new Display(4.3, 16000000));

            var calls = new List<Call>();
            calls.Add(new Call(DateTime.Now.AddDays(-2), "+359892412424", 99));
            calls.Add(new Call(DateTime.Now.AddDays(-3).AddHours(3.5), "+359884631253", 123));
            calls.Add(new Call(DateTime.Now.AddDays(-4), "+359874123173", 44));

            foreach (var call in calls)
            {
                myGSM.AddCallToHistory(call);
            }

            Console.WriteLine();
            myGSM.PrintCallHistory();

            Console.WriteLine();
            Console.WriteLine("Total price is: {0:C}", myGSM.GetTotalPriceOfCalls(0.37M));

            myGSM.RemoveLongestCallFromHistory();

            Console.WriteLine();
            Console.WriteLine("Total price without the longest call is: {0:C}", myGSM.GetTotalPriceOfCalls(0.37M));

            myGSM.ClearCallHistory();

            Console.WriteLine();
            myGSM.PrintCallHistory();
        }
Exemple #2
0
        public static void TestCallHistory()
        {
            GSM myGSM = new GSM("Xperia S", "Sony", 700, "Slim Shady",
                                new Battery(BatteryType.LiIon, "1750", 48, 24), new Display(4.3, 16000000));

            var calls = new List <Call>();

            calls.Add(new Call(DateTime.Now.AddDays(-2), "+359892412424", 99));
            calls.Add(new Call(DateTime.Now.AddDays(-3).AddHours(3.5), "+359884631253", 123));
            calls.Add(new Call(DateTime.Now.AddDays(-4), "+359874123173", 44));

            foreach (var call in calls)
            {
                myGSM.AddCallToHistory(call);
            }

            Console.WriteLine();
            myGSM.PrintCallHistory();

            Console.WriteLine();
            Console.WriteLine("Total price is: {0:C}", myGSM.GetTotalPriceOfCalls(0.37M));

            myGSM.RemoveLongestCallFromHistory();

            Console.WriteLine();
            Console.WriteLine("Total price without the longest call is: {0:C}", myGSM.GetTotalPriceOfCalls(0.37M));

            myGSM.ClearCallHistory();

            Console.WriteLine();
            myGSM.PrintCallHistory();
        }
Exemple #3
0
        public static void Test()
        {
            const decimal pricePerMinute = 0.37m;
            GSM           myGsm          = new GSM("Sony", "Experia e4");

            myGsm.AddCallToHistory(
                new Call(
                    new DateTime(2015, 2, 16, 21, 22, 3),
                    "+3592 1111111111",
                    new TimeSpan(0, 12, 45)));
            myGsm.AddCallToHistory(
                new Call(
                    new DateTime(2015, 2, 17, 20, 22, 3),
                    "+3592 2222222222",
                    new TimeSpan(0, 10, 32)));
            myGsm.AddCallToHistory(
                new Call(
                    new DateTime(2015, 2, 19, 17, 29, 35),
                    "+3592 1111111111",
                    new TimeSpan(0, 7, 3)));
            myGsm.AddCallToHistory(
                new Call(
                    new DateTime(2015, 3, 1, 0, 48, 53),
                    "+3592 3333333333",
                    new TimeSpan(0, 17, 38)));

            Console.WriteLine(myGsm.ToString());

            PrintCallHistory(myGsm);

            Console.WriteLine();

            decimal priceOfCallHistory = myGsm.PriceOfCallHistory(pricePerMinute);

            Console.WriteLine("total price: {0:F4}", priceOfCallHistory);
            Console.WriteLine();

            Call callToDelete = new Call(
                new DateTime(),
                "+3592 1111111111",
                new TimeSpan());

            Console.WriteLine("deleting last call by number: {0}", callToDelete.DialedNumber);

            myGsm.DeleteCallByNumber(callToDelete);
            PrintCallHistory(myGsm);

            Console.WriteLine();
            Console.WriteLine("deleting longest call");
            myGsm.DeleteLongesCall();
            PrintCallHistory(myGsm);

            priceOfCallHistory = myGsm.PriceOfCallHistory(pricePerMinute);
            Console.WriteLine("total price: {0:F4}", priceOfCallHistory);
            Console.WriteLine();

            Console.WriteLine("clearing all history");

            myGsm.ClearCallHistory();
            PrintCallHistory(myGsm);

            Console.WriteLine("history cleared");
        }