static void Main()
        {
            GSM someGSM = new GSM("Lumia", "Nokia");

            someGSM.AddCalls(DateTime.Now, "0889976484", 45);
            someGSM.AddCalls(DateTime.UtcNow, "088956454", 23);
            someGSM.AddCalls(DateTime.Now.AddHours(13), "0883076494", 5);

            for (int i = 0; i < someGSM.CallHistory.Count; i++)
            {
                Console.Write("{0}, {1}, {2}", someGSM.CallHistory[i].DateAndTime, someGSM.CallHistory[i].DialedPhoneNumber, someGSM.CallHistory[i].Duration);
                Console.WriteLine();
            }
            Console.WriteLine();
            someGSM.TotalPrice(0.37);

            someGSM.CallHistory.OrderByDescending(a => a.Duration);
            someGSM.CallHistory.RemoveAt(0);

            Console.WriteLine();
            someGSM.TotalPrice(0.37);

            Console.WriteLine();
            someGSM.ClearHistory();
            for (int i = 0; i < someGSM.CallHistory.Count; i++)
            {
                Console.Write("{0}, {1}, {2}", someGSM.CallHistory[i].DateAndTime, someGSM.CallHistory[i].DialedPhoneNumber, someGSM.CallHistory[i].Duration);
                Console.WriteLine();
            }
        }
        static void Main()
        {
            GSM someGSM = new GSM("Lumia", "Nokia");

            someGSM.AddCalls(DateTime.Now, "0889976484", 45);
            someGSM.AddCalls(DateTime.UtcNow, "088956454", 23);
            someGSM.AddCalls(DateTime.Now.AddHours(13), "0883076494", 5);

            for (int i = 0; i < someGSM.CallHistory.Count; i++)
            {
                Console.Write("{0}, {1}, {2}", someGSM.CallHistory[i].DateAndTime, someGSM.CallHistory[i].DialedPhoneNumber, someGSM.CallHistory[i].Duration);
                Console.WriteLine();
            }
            Console.WriteLine();
            someGSM.TotalPrice(0.37);

            someGSM.CallHistory.OrderByDescending(a => a.Duration);
            someGSM.CallHistory.RemoveAt(0);

            Console.WriteLine();
            someGSM.TotalPrice(0.37);

            Console.WriteLine();
            someGSM.ClearHistory();
            for (int i = 0; i < someGSM.CallHistory.Count; i++)
            {
                Console.Write("{0}, {1}, {2}", someGSM.CallHistory[i].DateAndTime, someGSM.CallHistory[i].DialedPhoneNumber, someGSM.CallHistory[i].Duration);
                Console.WriteLine();
            }
        }
        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));
        }
        static void Main()
        {
            //Create an instance of the GSM class.
            GSM myPhone = new GSM("One", "One Plus");

            myPhone.Owner                 = "I";
            myPhone.Price                 = 1000;
            myPhone.DisplaySize           = 5;
            myPhone.DisplayNumberOfColors = 16000000;
            myPhone.battery.Type          = BatteryType.LiIon;
            myPhone.battery.Model         = "RBC18";
            myPhone.battery.HoursIdleTime = 426.5;
            myPhone.battery.HoursTalkTime = 24.3;
            myPhone.AddCallToList(new Call(DateTime.Now, "0885649596", 5));
            //Add few calls.
            for (int i = 10; i < 60; i = i + 5)
            {
                myPhone.AddCallToList(new Call(DateTime.Now.AddMinutes(i), "08856495" + i, i));
            }
            for (int i = 80; i > 65; i = i - 3)
            {
                myPhone.AddCallToList(new Call(DateTime.Now.AddMinutes(i), "08856495" + i, i));
            }
            Console.WriteLine(myPhone.ToString());
            //Display the information about the calls.
            foreach (var call in myPhone.CallHistory)
            {
                Console.WriteLine("{0} - Phone number: {1} - Duration: {2}", call.Time, call.PhoneNumber, call.Duration);
            }
            Console.WriteLine("Total talk time: {0}", myPhone.TotalTalkTime());
            //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
            Console.WriteLine("The total price of the calls in the history is : {0}", myPhone.CallPrice(0.37M));
            //Remove the longest call from the history and calculate the total price again.
            myPhone.DeleteCallFromList(FindLongestCall(myPhone.CallHistory));
            foreach (var call in myPhone.CallHistory)
            {
                Console.WriteLine("{0} - Phone number: {1} - Duration: {2}", call.Time, call.PhoneNumber, call.Duration);
            }
            Console.WriteLine("Total talk time: {0}", myPhone.TotalTalkTime());
            Console.WriteLine("The total price of the calls in the history is : {0}", myPhone.CallPrice(0.37M));
            //Finally clear the call history and print it.
            myPhone.ClearCallHistory();
            foreach (var call in myPhone.CallHistory)
            {
                Console.WriteLine("{0} - Phone number: {1} - Duration: {2}", call.Time, call.PhoneNumber, call.Duration);
            }
            Console.WriteLine("Total talk time: {0}", myPhone.TotalTalkTime());
            Console.WriteLine("The total price of the calls in the history is : {0}", myPhone.CallPrice(0.37M));
        }
        //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 Test()
        {
            GSM[] gsmArr = new GSM[3]
            {
                new GSM("Lumia ", " Nokia ", 850, " Pesho"),
                new GSM("Lumia925 ", " Nokia ", 450, " Gosho"),
                new GSM("3310 ", " Nokia ", 50, " Ivan"),
            };

            foreach (GSM item in gsmArr)
            {
                Console.WriteLine(item.ToString());
            }
            Console.WriteLine();
            Console.WriteLine("Apple phone: ");
            Console.WriteLine(GSM.IPhone4S);
        }
        static void Test()
        {
            GSM[] gsmArr = new GSM[3]
            {
            new GSM("Lumia ", " Nokia ", 850, " Pesho"),
            new GSM("Lumia925 ", " Nokia ", 450, " Gosho"),
            new GSM("3310 ", " Nokia ", 50, " Ivan"),
            };

            foreach (GSM item in gsmArr)
            {
                Console.WriteLine(item.ToString());
            }
            Console.WriteLine();
            Console.WriteLine("Apple phone: ");
            Console.WriteLine(GSM.IPhone4S);
        }
        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));
        }
        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);
        }
        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();
        }
Exemple #12
0
 static GSM()
 {
     iPhone = new GSM("iPhone 4S", "Apple", 1000, "Will Smith",
         new Battery("Apple", 12, 36, BatteryType.LiIon), new Display(7, 16000000));
 }
Exemple #13
0
 static GSM()
 {
     iPhone = new GSM("iPhone 4S", "Apple", 1000, "Will Smith",
                      new Battery("Apple", 12, 36, BatteryType.LiIon), new Display(7, 16000000));
 }