Exemplo n.º 1
0
        public static void testCallHistory()
        {
            GSM testGSM = new GSM("Vibe Shor z90", "Lenovo", 199.99m, "Joro", new Battery("Chinese", 208.5f, 13.8f, BatteryType.LiPol), new Display("1920x1080", "16M"));

            testGSM.AddCall(new Call(DateTime.Now, "+359898987413", 85));
            testGSM.AddCall(new Call(new DateTime(2016, 03, 17, 15, 43, 27), "+359898257413", 185));
            testGSM.AddCall(new Call(new DateTime(2016, 03, 18, 15, 43, 27), "+3598981234563", 560));
            testGSM.AddCall(new Call(new DateTime(2016, 02, 18, 15, 43, 27), "+359898987413", 85));

            Call longestCall = testGSM.callHistory[0];

            foreach (var call in testGSM.callHistory)
            {
                Console.WriteLine(call);
                if (longestCall.Duration < call.Duration)
                {
                    longestCall = call;
                }
            }
            Console.WriteLine(testGSM.CallsPrice());
            testGSM.RemoveCall(longestCall);
            Console.WriteLine(testGSM.CallsPrice());
            testGSM.PrintCallHistory();
            testGSM.ClearCalls();
            testGSM.PrintCallHistory();
        }
 public static void TestAddCalls(GSM testPhone)
 {
     testPhone.AddCall(new DateTime(2014, 12, 21, 8, 3, 14), "Pesho", 14); //add some calls
     testPhone.AddCall(new DateTime(2014, 12, 21, 8, 43, 12), "Gosho", 218);
     testPhone.AddCall(new DateTime(2014, 12, 21, 18, 14, 43), "Stamat", 32);
     testPhone.AddCall(new DateTime(2014, 12, 21, 12, 54, 53), "Hasan", 5);
 }
Exemplo n.º 3
0
        static void Main()
        {
            Battery myBattery  = new Battery("B. M.", 15, 56, BatteryType.NiMH);
            Battery myBattery1 = new Battery("B. M.", 17, 68, BatteryType.LiIon);
            Battery myBattery2 = new Battery("B. M.", 16, 69, BatteryType.NiCd);

            GSM gsm = new GSM("S6", "Samsung", 500.03m, "Pesho", myBattery);

            Console.WriteLine(gsm + "\n");
            Console.WriteLine(GSM.IPhone + "\n");

            GSM gsm1 = new GSM("S1", "Samsung", 100.09m, "Pesho", myBattery);
            GSM gsm2 = new GSM("S2", "Samsung", 200.09m, "Pesho", myBattery1);
            GSM gsm3 = new GSM("S3", "Samsung", 300.09m, "Pesho", myBattery2);
            GSM gsm4 = new GSM("S4", "Samsung", 400.09m, "Pesho", myBattery1);

            List <GSM> gsmList = new List <GSM>()
            {
                gsm1, gsm2, gsm3, gsm4
            };

            foreach (var telephone in gsmList)
            {
                Console.WriteLine(telephone);
            }

            DateTime date1 = new DateTime(2008, 8, 29, 19, 27, 15, 18);
            DateTime date2 = new DateTime(2014, 8, 30, 19, 22, 15, 18);
            DateTime date3 = new DateTime(2014, 9, 15, 10, 12, 14, 44);

            CultureInfo ci = CultureInfo.InvariantCulture;

            Call call1 = new Call(date1, date1, "+359878864612", 120);
            Call call2 = new Call(date2, date2, "+359871164612", 820);
            Call call3 = new Call(date3, date3, "+359872264612", 320);

            gsm.AddCall(call1);
            gsm.AddCall(call2);
            gsm.AddCall(call3);

            var calls = gsm.GetCalls();

            gsm.DisplayCallsInfo();

            Console.WriteLine("\nTotal price of the calls in the history is {0} BGN\n", gsm.CallPrice());

            var longestCall = calls.OrderByDescending(x => x.CallDurationInSeconds).First();

            gsm.DeleteCall(longestCall);

            Console.WriteLine("Phone call deleted");
            Console.WriteLine("\nTotal price of the calls in the history is {0} BGN\n", gsm.CallPrice());

            gsm.ClearCallHistory();
            gsm.DisplayCallsInfo();
        }
Exemplo n.º 4
0
        static void Main()
        {
            Battery myBattery = new Battery("B. M.", 15, 56, BatteryType.NiMH);
            Battery myBattery1 = new Battery("B. M.", 17, 68, BatteryType.LiIon);
            Battery myBattery2 = new Battery("B. M.", 16, 69, BatteryType.NiCd);

            GSM gsm = new GSM("S6", "Samsung", 500.03m, "Pesho", myBattery);
            Console.WriteLine(gsm + "\n");
            Console.WriteLine(GSM.IPhone + "\n");

            GSM gsm1 = new GSM("S1", "Samsung", 100.09m, "Pesho", myBattery);
            GSM gsm2 = new GSM("S2", "Samsung", 200.09m, "Pesho", myBattery1);
            GSM gsm3 = new GSM("S3", "Samsung", 300.09m, "Pesho", myBattery2);
            GSM gsm4 = new GSM("S4", "Samsung", 400.09m, "Pesho", myBattery1);

            List<GSM> gsmList = new List<GSM>() { gsm1, gsm2, gsm3, gsm4 };

            foreach (var telephone in gsmList)
            {
                Console.WriteLine(telephone);
            }

            DateTime date1 = new DateTime(2008, 8, 29, 19, 27, 15, 18);
            DateTime date2 = new DateTime(2014, 8, 30, 19, 22, 15, 18);
            DateTime date3 = new DateTime(2014, 9, 15, 10, 12, 14, 44);

            CultureInfo ci = CultureInfo.InvariantCulture;

            Call call1 = new Call(date1, date1, "+359878864612", 120);
            Call call2 = new Call(date2, date2, "+359871164612", 820);
            Call call3 = new Call(date3, date3, "+359872264612", 320);

            gsm.AddCall(call1);
            gsm.AddCall(call2);
            gsm.AddCall(call3);

            var calls = gsm.GetCalls();

            gsm.DisplayCallsInfo();

            Console.WriteLine("\nTotal price of the calls in the history is {0} BGN\n", gsm.CallPrice());

            var longestCall = calls.OrderByDescending(x => x.CallDurationInSeconds).First();
            gsm.DeleteCall(longestCall);

            Console.WriteLine("Phone call deleted");
            Console.WriteLine("\nTotal price of the calls in the history is {0} BGN\n", gsm.CallPrice());

            gsm.ClearCallHistory();
            gsm.DisplayCallsInfo();
        }
        public static void Main()
        {
            GSM myGSM = new GSM(
                    "Asha 205 ",
                    "Nokia",
                    "Nikolay Kostadinov",
                    120m,
                    "Nokia",
                    200,
                    10,
                    4,
                    65000u);
            
            Random rnd = new Random();
            
            for (int i = 1; i < 50; i++)
            {
                Call call = new Call("+359886630111", (uint)rnd.Next(45, 200));
                myGSM.AddCall(call);
            }

            Console.WriteLine(GSM.Iphone4S);

            DisplayCallHistory(myGSM);
            Console.ReadKey();
            DeleteMaxDurationCall(myGSM);
            DisplayCallHistory(myGSM);
        }
        public static void TestCalls()
        {
            //Add few calls.
            sagem.AddCall(new Call("31.3.2015 9:08:33", "+413 334 123", 60));
            sagem.AddCall(new Call("3.05.2015 22:45:00", "+359 123 120", 112));
            sagem.AddCall(new Call("2.03.2015 03:15:09", "+359 124 554", 122));
            sagem.AddCall(new Call("10.03.2015 06:05:12", "+359 125 098", 2));

            //Display the information about the calls.
            Console.WriteLine();
            Console.WriteLine("Call-list info: ");
            DisplayCalls();

            //Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
            Console.WriteLine();
            Console.WriteLine("Total price:");
            Console.WriteLine(string.Format(CultureInfo.CreateSpecificCulture("en-US"), "{0:C2}", sagem.Account(0.37M)));

            //Remove the longest call from the history and calculate the total price again.
            int indexOfMaxDuration = 0;

            for (int i = 0; i < sagem.CallHistory.Capacity; i++)
            {
                if (sagem.CallHistory[i].Duration > indexOfMaxDuration)
                {
                    indexOfMaxDuration = i;
                }
            }
            sagem.DeleteCall(sagem.CallHistory[indexOfMaxDuration]);

            Console.WriteLine();
            Console.WriteLine("Reduced call-list info: ");
            DisplayCalls();

            Console.WriteLine();
            Console.WriteLine("Total price after the remove:");
            Console.WriteLine(string.Format(CultureInfo.CreateSpecificCulture("en-US"), "{0:C2}", sagem.Account(priceOfMinute)));
            Console.WriteLine();

            //Finally clear the call history
            Console.WriteLine("Clearing the call history:");
            sagem.DeleteCallHistory();
            Console.WriteLine();
            Console.WriteLine("Displaying the resulting call history:");
            DisplayCalls();
        }
Exemplo n.º 7
0
        public void Functionality()
        {
            Gsm.AddCall(new Call(new DateTime(2016, 06, 09, 12, 00, 05), "0888 88 88 88", 100));
            Gsm.AddCall(new Call(new DateTime(2016, 06, 06, 13, 04, 10), "0777 77 77 77", 200));

            Console.WriteLine(Gsm.CallHistory);

            Console.WriteLine("Total price: {0} BGN", Gsm.GetPrice(PricePerMinute));

            Gsm.RemoveLongestCall();

            Console.WriteLine(
                "Total price after removing longest call is {0} BGN", Gsm.GetPrice(PricePerMinute));

            Gsm.ClearHistory();

            Console.WriteLine(Gsm.CallHistory);
        }
        public static void GenerateCallHistory()
        {
            // Create an instance of the GSM class
            GSM myGSM = new GSM("G2", "LG", 560m, "Pesho",
                                new Battery("Li-Po", 790, 16, BatteryType.LiIon), new Display(5.2, 16000000));

            //Add few calls
            myGSM.AddCall(new Call(new DateTime(2015, 3, 10, 20, 53, 20), "0881234567", 65));
            myGSM.AddCall(new Call(new DateTime(2015, 3, 9, 15, 25, 47), "0889876543", 130));
            myGSM.AddCall(new Call(new DateTime(2015, 3, 7, 11, 47, 10), "0891112223", 239));
            myGSM.AddCall(new Call(new DateTime(2015, 2, 28, 19, 37, 32), "0988854321", 167));

            // Display the information about the calls
            myGSM.PrintCallHistory();

            //  Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history
            decimal totalPriceOfCalls = myGSM.CalculateCallsPrice(0.37m);

            Console.WriteLine("Total price of calls in the history: {0:0.00}", totalPriceOfCalls);

            // Remove the longest call from the history and calculate the total price again
            Call longestCall = myGSM.CallHistory[0];

            foreach (Call call in myGSM.CallHistory)
            {
                if (call.Duration > longestCall.Duration)
                {
                    longestCall = call;
                }
            }

            myGSM.DeleteCall(longestCall);

            totalPriceOfCalls = myGSM.CalculateCallsPrice(0.37m);
            Console.WriteLine("Total price of calls in the history after removing the longest call: {0:0.00} \n", totalPriceOfCalls);

            // Finally clear the call history and print it
            myGSM.ClearCallHistory();
            myGSM.PrintCallHistory();
        }
        public static void GenerateCallHistory()
        {
            // Create an instance of the GSM class
            GSM myGSM = new GSM("G2", "LG", 560m, "Pesho",
                new Battery("Li-Po", 790, 16, BatteryType.LiIon), new Display(5.2, 16000000));

            //Add few calls
            myGSM.AddCall(new Call(new DateTime(2015, 3, 10, 20, 53, 20), "0881234567", 65));
            myGSM.AddCall(new Call(new DateTime(2015, 3, 9, 15, 25, 47), "0889876543", 130));
            myGSM.AddCall(new Call(new DateTime(2015, 3, 7, 11, 47, 10), "0891112223", 239));
            myGSM.AddCall(new Call(new DateTime(2015, 2, 28, 19, 37, 32), "0988854321", 167));

            // Display the information about the calls
            myGSM.PrintCallHistory();

            //  Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history
            decimal totalPriceOfCalls = myGSM.CalculateCallsPrice(0.37m);
            Console.WriteLine("Total price of calls in the history: {0:0.00}", totalPriceOfCalls);

            // Remove the longest call from the history and calculate the total price again
            Call longestCall = myGSM.CallHistory[0];

            foreach (Call call in myGSM.CallHistory)
            {
                if (call.Duration > longestCall.Duration)
                {
                    longestCall = call;
                }
            }

            myGSM.DeleteCall(longestCall);

            totalPriceOfCalls = myGSM.CalculateCallsPrice(0.37m);
            Console.WriteLine("Total price of calls in the history after removing the longest call: {0:0.00} \n", totalPriceOfCalls);

            // Finally clear the call history and print it
            myGSM.ClearCallHistory();
            myGSM.PrintCallHistory();
        }
Exemplo n.º 10
0
 public static void Calls()
 {
     GSM myGsm = new GSM("One X", "HTC", 800, "Georgi", new Battery("Li/Ion", 200, 7), new Display(4.7, 160000000));
     myGsm.AddCall("0878182854", 213);
     myGsm.AddCall("0898625311", 51);
     myGsm.AddCall("0898694325", 118);
     foreach (var item in myGsm.GetCallHistory)
     {
         Console.WriteLine("Call to: "+item.phoneNumber);
         Console.WriteLine("Duration: "+item.duration);
         Console.WriteLine("Date: "+item.date);
         Console.WriteLine();
     }
     Console.WriteLine("Total price: {0}", myGsm.TotalPriceOfCalls(0.37));
     //Remove the longest call
     int max=0;
     int index=0;
     foreach (var item in myGsm.GetCallHistory)
     {
         if (item.duration > max)
         {
             max = item.duration;
             index = myGsm.GetCallHistory.IndexOf(item);
         }
     }
     GSM.callHistory.RemoveAt(index);
     Console.WriteLine("Total price: {0}", myGsm.TotalPriceOfCalls(0.37));
     //Clear all history and print it
     myGsm.ClearAllCallHistory();
     foreach (var item in myGsm.GetCallHistory)
     {
         Console.WriteLine("Call to: " + item.phoneNumber);
         Console.WriteLine("Duration: " + item.duration);
         Console.WriteLine("Date: " + item.date);
         Console.WriteLine();
     }
 }
        public static void TestCallHistory()
        {
            var battery = new Battery("Moqta firma za baterii", "Moqt model bateriq", 100, 150, BatteryType.LiIon);
            var display = new Display("Moqta firma za displejove", "Moqt model display", 5.6, "1900 x 600");
            var gsm     = new GSM("Moqta firma", "Moqt model", battery, display, "Az sym owner", 1900);

            for (int i = 0; i < 10; i++)
            {
                gsm.AddCall(new Call(DateTime.Now.ToString(), i, "087830" + i));
            }

            gsm.RemoveLastCall();
            Console.WriteLine(gsm.CallBill(1));
            gsm.ClearCallHistory();
            Console.WriteLine(gsm.CallBill(1));
        }