static void Main()
        {
            Battery samsungBattery = new Battery("EB-L1G6LLA", 30, 15, BatteryType.NiMH);
            Display bigDisplay     = new Display(11, 16000000);
            GSM     samsungNote    = new GSM("GalaxyNote", "Samsung", 600.00, "Samsung", samsungBattery, bigDisplay);


            decimal pricePerMin = 0.37M;

            Calls call = new Calls(DateTime.Today, DateTime.Now.TimeOfDay, "+359887841089", 120);

            samsungNote.AddCall(call);
            Calls call2 = new Calls(DateTime.Today, DateTime.Now.TimeOfDay, "+359887845655", 400);

            samsungNote.AddCall(call2);
            Calls call3 = new Calls(DateTime.Today, DateTime.Now.TimeOfDay, "+359888999954", 324);

            samsungNote.AddCall(call3);
            Calls call4 = new Calls(DateTime.Today, DateTime.Now.TimeOfDay, "+359854454322", 487);

            samsungNote.AddCall(call4);


            Console.WriteLine("SORTED CALL LIST");
            List <Calls> tempList = samsungNote.HISTORY;

            tempList.Sort();
            foreach (var calls in tempList)
            {
                Console.WriteLine(calls.ToString());
            }

            Console.WriteLine("\nPrice per minute is: {0}. Total cost: {1}\n", pricePerMin.ToString("C", CultureInfo.CurrentCulture), samsungNote.CalculateCalls(pricePerMin).ToString("C", CultureInfo.CurrentCulture));


            Console.WriteLine("DELETING THE LONGEST CALL");
            samsungNote.DeleteCall(tempList[tempList.Count - 1]);

            foreach (var calls in tempList)
            {
                Console.WriteLine(calls.ToString());
            }

            Console.WriteLine("\nPrice per minute is: {0}. Total cost: {1}\n", pricePerMin.ToString("C", CultureInfo.CurrentCulture), samsungNote.CalculateCalls(pricePerMin).ToString("C", CultureInfo.CurrentCulture));


            Console.WriteLine("CLEARING THE WHOLE CALL LIST");
            samsungNote.ClearCall();
            foreach (var calls in tempList)
            {
                Console.WriteLine(calls.ToString());
            }
            Console.WriteLine("\nPrice per minute is: {0}. Total cost: {1}\n", pricePerMin.ToString("C", CultureInfo.CurrentCulture), samsungNote.CalculateCalls(pricePerMin).ToString("C", CultureInfo.CurrentCulture));
        }
Ejemplo n.º 2
0
        //12.Write a class GSMCallHistoryTest to test the call history functionality of the GSM class.
        //-Create an instance of the GSM class.
        //-Add few calls.
        //-Display the information about the calls.
        //-Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
        //-Remove the longest call from the history and calculate the total price again.
        //-Finally clear the call history and print it.

        static void Main()
        {
            const decimal callPerMinutePrice = 0.37M;

            GSM phone = new GSM("Galaxy S2", "Samsung", 450, "Gogo", new Battery("A1920", BatteryType.LiIon), new Display(3.2M, 100000UL));

            phone.AddCall(new Call("29.02.2012", "10:10:10", "0845333444", 60));
            phone.AddCall(new Call("15.12.2013", "12:00:00", "0879123456", 480));
            phone.AddCall(new Call("20.07.2011", "15:00:00", "0863123456", 960));

            //print every call information
            foreach (Call call in phone.CallHistory)
            {
                Console.WriteLine(call.ToString());
                Console.WriteLine();
            }

            decimal phoneCallsPrice = phone.CalculateCallsPrice(callPerMinutePrice);

            Console.WriteLine("Total cost of all calls: {0}", phoneCallsPrice);
            Console.WriteLine();

            phone.DeleteCall(2);

            phoneCallsPrice = phone.CalculateCallsPrice(callPerMinutePrice);
            Console.WriteLine("Total cost of all calls after deleted the longest call: {0}", phoneCallsPrice);
            Console.WriteLine();

            //after the deleted call
            Console.ForegroundColor = ConsoleColor.Cyan;
            foreach (var call in phone.CallHistory)
            {
                Console.WriteLine(call.ToString());
                Console.WriteLine();
            }

            phone.ClearCallHistory();
            //try to print calls, but history is deleted
            //there is no calls in the call history and nothing happens
            foreach (var call in phone.CallHistory)
            {
                Console.WriteLine(call.ToString());
                Console.WriteLine();
            }
            Console.ResetColor();
        }
        static void Main()
        {
            Battery samsungBattery = new Battery("EB-L1G6LLA", 30, 15, BatteryType.NiMH);
            Display bigDisplay = new Display(11, 16000000);
            GSM samsungNote = new GSM("GalaxyNote", "Samsung", 600.00, "Samsung", samsungBattery, bigDisplay);

            decimal pricePerMin = 0.37M;

            Calls call = new Calls( DateTime.Today, DateTime.Now.TimeOfDay, "+359887841089", 120);
            samsungNote.AddCall(call);
            Calls call2 = new Calls(DateTime.Today, DateTime.Now.TimeOfDay, "+359887845655", 400);
            samsungNote.AddCall(call2);
            Calls call3 = new Calls(DateTime.Today, DateTime.Now.TimeOfDay, "+359888999954", 324);
            samsungNote.AddCall(call3);
            Calls call4 = new Calls(DateTime.Today, DateTime.Now.TimeOfDay, "+359854454322", 487);
            samsungNote.AddCall(call4);

            Console.WriteLine("SORTED CALL LIST");
            List<Calls> tempList = samsungNote.HISTORY;
            tempList.Sort();
            foreach (var calls in tempList)
            {

                Console.WriteLine(calls.ToString());
            }

            Console.WriteLine("\nPrice per minute is: {0}. Total cost: {1}\n", pricePerMin.ToString("C", CultureInfo.CurrentCulture), samsungNote.CalculateCalls(pricePerMin).ToString("C", CultureInfo.CurrentCulture));

            Console.WriteLine("DELETING THE LONGEST CALL");
            samsungNote.DeleteCall(tempList[tempList.Count - 1]);

            foreach (var calls in tempList)
            {
                Console.WriteLine(calls.ToString());
            }

            Console.WriteLine("\nPrice per minute is: {0}. Total cost: {1}\n", pricePerMin.ToString("C", CultureInfo.CurrentCulture), samsungNote.CalculateCalls(pricePerMin).ToString("C", CultureInfo.CurrentCulture));

            Console.WriteLine("CLEARING THE WHOLE CALL LIST");
            samsungNote.ClearCall();
            foreach (var calls in tempList)
            {
                Console.WriteLine(calls.ToString());
            }
            Console.WriteLine("\nPrice per minute is: {0}. Total cost: {1}\n", pricePerMin.ToString("C", CultureInfo.CurrentCulture), samsungNote.CalculateCalls(pricePerMin).ToString("C", CultureInfo.CurrentCulture));
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            GSM nokia = new GSM("lumia", "nokia", 900, "Stoyan", new Battery("Asperji", 30, 0, Battery.BatteryType.NiMH), new Display("366x512", 16000000));

            nokia.AddCall(new Call("02.04.2015", "02:22:32", "0884239123", (long)340));
            nokia.AddCall(new Call("01.10.2015", "12:12:42", "0884232345", (long)245));
            nokia.AddCall(new Call("02.04.2015", "15:33:12", "0889123242", (long)45));

            //display info for each call
            foreach (var call in nokia.callHistory)
            {
                Console.WriteLine(call.ToString());
                Console.WriteLine();
            }

            //total price of calls

            Console.WriteLine("Total price of all calls (0.37 per minute) : " + nokia.TotalPriceOfCalls(0.37m));
            Console.WriteLine();

            long?max = 0;
            Call c   = new Call();

            foreach (Call call in nokia.callHistory)
            {
                if (call.Duration > max)
                {
                    max = call.Duration;
                    c   = call;
                }
            }

            nokia.callHistory.Remove(c);

            Console.WriteLine("Total price of all calls after removal (0.37 per minute) : " + nokia.TotalPriceOfCalls(0.37m));

            nokia.callHistory.Clear();

            //print after removal of all elements
            foreach (var call in nokia.callHistory)
            {
                Console.WriteLine(call);
            }
            Console.WriteLine();
        }
        static void Main()
        {
            GSM testPhone = new GSM("Lumia", "Microsoft");

            testPhone.AddCall(new DateTime(2015, 1, 1), 0888123456, 50);
            testPhone.AddCall(new DateTime(2015, 1, 10), 0888123456, 50);
            testPhone.AddCall(DateTime.Now, 0888123456, 100);

            PrintCalls(testPhone.CallHistory);

            Console.WriteLine("Total price is {0}", testPhone.TotalCallsPrice(0.37));

            int longestCallIndex = FindLongestCall(testPhone.CallHistory);

            testPhone.DeleteCall(longestCallIndex);

            Console.WriteLine("Total price after removal of longest call is {0}", testPhone.TotalCallsPrice(0.37));

            testPhone.ClearCallHistory();

            PrintCalls(testPhone.CallHistory);
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            // GSM 1
            GSM nokia = new GSM("Nokia", "Nokia", 15, "Nokia");
            // Add Calls
            Call c1 = new Call("11/14/2001", "14:27:36", "+123456", 900);
            Call c2 = new Call("11/19/2001", "14:56:36", "+359883442324", 800);
            Call c3 = new Call("11/19/2001", "12:27:36", "+359883442324", 800);

            nokia.AddCall(c1);
            nokia.AddCall(c2);
            nokia.AddCall(c3);
            // Display Calls Info
            nokia.PrintCallHistory();
            // Display Total Price of All Calls
            Console.WriteLine("Total Price of All Calls:{0:C2}", nokia.CallsTotalPrice(0.37m));
            // Remove Call
            nokia.RemoveCall(c1);
            Console.WriteLine("Total Price of All Calls:{0:C2}", nokia.CallsTotalPrice(0.37m));
            // Clear Call History
            nokia.RemoveAllCalls();
            nokia.PrintCallHistory();
        }