예제 #1
0
        private static void CallTest()
        {
            GSM testGSM = new GSM("Nokia", "Lumia", 400, "Nikoi", new Battery("0093/478AS/9IOF1", 240, 17, BatteryType.NiCd), new Display(6.3, 16));

            testGSM.AddCall("12.04.2014", "14:33:58", "0883456629", 100);
            testGSM.AddCall("12.04.2014", "20:22:00", "0883454629", 300);
            testGSM.AddCall("12.05.2014", "10:12:45", "0889834231", 540);
            testGSM.AddCall("01.01.2015", "09:09:37", "0883454629", 240);
            testGSM.AddCall("12.05.2014", "11:00:03", "0889834231", 70);

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(testGSM.ShowHistory());
            Console.ResetColor();

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("Total call price: {0:F2}", testGSM.TotalCallPrice(0.37m));
            Console.ResetColor();

            testGSM.RemoveCall(3);

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("The total call price after deleting the longest call: {0:F2}", testGSM.TotalCallPrice(0.37m));
            Console.ResetColor();

            testGSM.ClearHistory();
            Console.WriteLine("Call history deleted!!!");

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(testGSM.ShowHistory());
            Console.ResetColor();
        }
예제 #2
0
        private static void CallTest()
        {
            GSM testGSM = new GSM("Nokia", "Lumia", 400, "Nikoi", new Battery("0093/478AS/9IOF1", 240, 17, BatteryType.NiCd), new Display(6.3, 16));

            testGSM.AddCall("12.04.2014", "14:33:58", "0883456629", 100);
            testGSM.AddCall("12.04.2014", "20:22:00", "0883454629", 300);
            testGSM.AddCall("12.05.2014", "10:12:45", "0889834231", 540);
            testGSM.AddCall("01.01.2015", "09:09:37", "0883454629", 240);
            testGSM.AddCall("12.05.2014", "11:00:03", "0889834231", 70);

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(testGSM.ShowHistory());
            Console.ResetColor();

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("Total call price: {0:F2}", testGSM.TotalCallPrice(0.37m));
            Console.ResetColor();

            testGSM.RemoveCall(3);

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("The total call price after deleting the longest call: {0:F2}", testGSM.TotalCallPrice(0.37m));
            Console.ResetColor();

            testGSM.ClearHistory();
            Console.WriteLine("Call history deleted!!!");

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(testGSM.ShowHistory());
            Console.ResetColor();
        }
예제 #3
0
        public static void TestGSMCalls()
        {
            GSM phone = new GSM("G3", "LG");

            phone.AddCall(new DateTime(2016, 10, 27, 10, 35, 12), "+359888888888", 137);
            phone.AddCall(new DateTime(2016, 10, 29, 19, 35, 12), "+359888888888", 13);
            phone.AddCall(new DateTime(2016, 10, 28, 17, 35, 12), "+359888123456", 2232);
            phone.AddCall(new DateTime(2016, 10, 29, 13, 35, 12), "+359888654321", 101);
            phone.AddCall(new DateTime(2016, 10, 29, 19, 35, 12), "+359888888888", 128);

            Console.WriteLine(phone.CallHistoryToString());

            Console.WriteLine("Total price of all list: {0}", phone.CallHistoryTotalPrice(0.37));

            int  maxDuration         = 0;
            Call callWithMaxDuration = phone.CallHistory[0];

            foreach (Call call in phone.CallHistory)
            {
                if (call.DurationInSec >= maxDuration)
                {
                    maxDuration         = call.DurationInSec;
                    callWithMaxDuration = call;
                }
            }

            phone.RemoveCall(callWithMaxDuration);

            Console.WriteLine("Total price of all list after removing longest call: {0}", phone.CallHistoryTotalPrice(0.37));
        }
예제 #4
0
        public void Start()
        {
            GSM phone = new GSM("GalaxyJ5", "Samsung", 300, "Stoyan", 80, 24, BatteryType.LiIon, 1600, 3);

            phone.AddCall("29.05", "12:13", "0888015508", 167);
            phone.AddCall("29.05", "13:25", "0888015508", 305);
            phone.AddCall("30.05", "06:03", "290501515", 12);

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

            phone.PriceOfCalls(0.37);

            int longestCall      = 0;
            int longestCallIndex = 0;

            for (int i = 0; i < phone.CallHistory.Count; i++)
            {
                int callDuration = int.Parse(phone.CallHistory[i].GetCall().Split(',')[3]);
                if (callDuration > longestCall)
                {
                    longestCall      = callDuration;
                    longestCallIndex = i;
                }
            }

            phone.DelCall(phone.CallHistory[longestCallIndex]);

            phone.PriceOfCalls(0.37);
            phone.PrintCallHistory();
            phone.ClearCallHistory();
        }
        public static void Test()
        {
            GSM LG = new GSM
                         ("G4", "LG", "Mary", 28.2M, new Battery("PDO098", 750, 650, BatteryType.NiMH), new Display(15, 55000));
            Call firstcall = new Call();

            firstcall.DateAndTime       = new DateTime(2017, 7, 20);
            firstcall.DialedNumber      = "0899731333";
            firstcall.DurationInSeconds = 180;

            Call secondcall = new Call();

            firstcall.DateAndTime       = new DateTime(2017, 7, 20);
            firstcall.DialedNumber      = "0899731333";
            firstcall.DurationInSeconds = 55;

            Call thirdcall = new Call();

            firstcall.DateAndTime       = new DateTime(2017, 7, 21);
            firstcall.DialedNumber      = "08972133399";
            firstcall.DurationInSeconds = 55;

            Call fourthcall = new Call();

            firstcall.DateAndTime       = new DateTime(2017, 7, 22);
            firstcall.DialedNumber      = "123";
            firstcall.DurationInSeconds = 67;

            LG.AddCall(firstcall);
            LG.AddCall(secondcall);
            LG.AddCall(thirdcall);
            LG.AddCall(fourthcall);

            firstcall.PrintCallDetails();
            secondcall.PrintCallDetails();
            thirdcall.PrintCallDetails();
            fourthcall.PrintCallDetails();

            decimal totalPrice = LG.CalcCallPrice(firstcall, 0.37M) +
                                 LG.CalcCallPrice(secondcall, 0.37M) +
                                 LG.CalcCallPrice(thirdcall, 0.37M) +
                                 LG.CalcCallPrice(fourthcall, 0.37M);

            Console.WriteLine($"Total price of calls = {totalPrice}");

            //to implement remove longest call from history

            LG.ClearCalls();
            Console.WriteLine($"Number of calls: {LG.GetCallHistory.Count}.");
        }
        public void TestFunctionality()
        {
            //  This is the default calls.
            //  Just for the test.

            Call firstCall  = new Call("05/03/2014", "12:23", "0884321", 20);
            Call secondCall = new Call("02/08/2015", "13:35", "07757454", 10);
            Call thirdCall  = new Call("04/04/2014", "23:34", "06908472", 12);

            testCalls.AddCall(firstCall);
            testCalls.AddCall(secondCall);
            testCalls.AddCall(thirdCall);

            Console.WriteLine(testCalls.TotalPriceOfTheCalls(0.37, testCalls.CallHistory.Count));

            testCalls.DeleteCall(firstCall);

            Console.WriteLine(testCalls.TotalPriceOfTheCalls(0.37, testCalls.CallHistory.Count));

            testCalls.ViewAllCallInformation(testCalls.CallHistory[0]);
            testCalls.ViewAllCallInformation(testCalls.CallHistory[1]);
        }