public static void CallHistoryTest()
        {
            //creating GSMs
            var iPhone6  = new GSM("Apple", "iPhone 6");
            var galaxyS6 = new GSM("Samsung", "Galaxy S 6");
            var g3       = new GSM("LG", "G3");

            //adding calls on each GSM's call history
            iPhone6.AddCall(new Call("21.05.2015 15:36:12", "+359888456891", 154));
            iPhone6.AddCall(new Call("22.05.2015 18:38:12", "+359878475896", 35));
            iPhone6.AddCall(new Call("25.05.2015 13:34:12", "+359898475126", 75));

            galaxyS6.AddCall(new Call());

            g3.AddCall(new Call("21.07.2015 15:36:12", "+359888476891", 78));
            g3.AddCall(new Call("7.08.2015 10:25:22", "+359876554015", 45));

            //printing call history and total price of calls
            Console.WriteLine(Environment.NewLine + iPhone6.Model);
            Console.WriteLine(iPhone6.CallHistory);
            Console.WriteLine(iPhone6.PriceOfCalls());

            Console.WriteLine(Environment.NewLine + galaxyS6.Model);
            Console.WriteLine(galaxyS6.CallHistory);
            Console.WriteLine(galaxyS6.PriceOfCalls());

            Console.WriteLine(Environment.NewLine + g3.Model);
            Console.WriteLine(g3.CallHistory);
            Console.WriteLine(g3.PriceOfCalls());

            //deleting call with maximal duration and printing call history and total price of calls
            iPhone6.DeleteCall();
            Console.WriteLine(Environment.NewLine + iPhone6.Model);
            Console.WriteLine(iPhone6.CallHistory);
            Console.WriteLine(iPhone6.PriceOfCalls());

            g3.DeleteCall();
            Console.WriteLine(Environment.NewLine + g3.Model);
            Console.WriteLine(g3.CallHistory);
            Console.WriteLine(g3.PriceOfCalls());

            //clearin call histrory
            iPhone6.ClearHistory();
            Console.WriteLine(Environment.NewLine + iPhone6.Model);
            Console.WriteLine(iPhone6.CallHistory);
            Console.WriteLine(iPhone6.PriceOfCalls());

            g3.ClearHistory();
            Console.WriteLine(Environment.NewLine + g3.Model);
            Console.WriteLine(g3.CallHistory);
            Console.WriteLine(g3.PriceOfCalls());
        }
        public static void CallHistoryTest()
        {
            //creating GSMs
            var iPhone6 = new GSM("Apple", "iPhone 6");
            var galaxyS6 = new GSM("Samsung", "Galaxy S 6");
            var g3 = new GSM("LG", "G3");

            //adding calls on each GSM's call history
            iPhone6.AddCall(new Call("21.05.2015 15:36:12", "+359888456891", 154));
            iPhone6.AddCall(new Call("22.05.2015 18:38:12", "+359878475896", 35));
            iPhone6.AddCall(new Call("25.05.2015 13:34:12", "+359898475126", 75));

            galaxyS6.AddCall(new Call());

            g3.AddCall(new Call("21.07.2015 15:36:12", "+359888476891", 78));
            g3.AddCall(new Call("7.08.2015 10:25:22", "+359876554015", 45));

            //printing call history and total price of calls
            Console.WriteLine(Environment.NewLine + iPhone6.Model);
            Console.WriteLine(iPhone6.CallHistory);
            Console.WriteLine(iPhone6.PriceOfCalls());

            Console.WriteLine(Environment.NewLine + galaxyS6.Model);
            Console.WriteLine(galaxyS6.CallHistory);
            Console.WriteLine(galaxyS6.PriceOfCalls());

            Console.WriteLine(Environment.NewLine + g3.Model);
            Console.WriteLine(g3.CallHistory);
            Console.WriteLine(g3.PriceOfCalls());

            //deleting call with maximal duration and printing call history and total price of calls
            iPhone6.DeleteCall();
            Console.WriteLine(Environment.NewLine + iPhone6.Model);
            Console.WriteLine(iPhone6.CallHistory);
            Console.WriteLine(iPhone6.PriceOfCalls());

            g3.DeleteCall();
            Console.WriteLine(Environment.NewLine + g3.Model);
            Console.WriteLine(g3.CallHistory);
            Console.WriteLine(g3.PriceOfCalls());

            //clearin call histrory
            iPhone6.ClearHistory();
            Console.WriteLine(Environment.NewLine + iPhone6.Model);
            Console.WriteLine(iPhone6.CallHistory);
            Console.WriteLine(iPhone6.PriceOfCalls());

            g3.ClearHistory();
            Console.WriteLine(Environment.NewLine + g3.Model);
            Console.WriteLine(g3.CallHistory);
            Console.WriteLine(g3.PriceOfCalls());
        }
        public static void CallTest()
        {
            // Create an instance of the GSM class.

            var newPhone = new GSM("test model", "random manufacturer");

            // Add few calls.

            newPhone.AddCall(DateTime.Now, 500, "0888424124");
            newPhone.AddCall(new DateTime(2016, 12, 31, 23, 58, 59), 1600, "0888444444");
            newPhone.AddCall(new DateTime(2016, 12, 21, 11, 23, 01), 2600, "0888444333");

            // Display the information about the calls.

            PrintCallHistory(newPhone);

            // Assuming that the price per minute is 0.37 calculate and print the total price of the calls in the history.
            // price is set as a constant in GSM class

            var totalPrice = newPhone.CalculateCallsPrice();

            Console.WriteLine("You must pay: {0:F2} leva", totalPrice);

            // Remove the longest call from the history and calculate the total price again.

            int longestCall      = 0;
            int indexLongestCall = 0;

            for (int i = 0; i < newPhone.CallHistory.Count; i++)
            {
                if (newPhone.CallHistory[i].Duration > longestCall)
                {
                    longestCall      = newPhone.CallHistory[i].Duration;
                    indexLongestCall = i;
                }
            }

            newPhone.DeleteCall(indexLongestCall);

            var newPrice = newPhone.CalculateCallsPrice();

            Console.WriteLine("You must pay: {0:F2} leva", newPrice);


            // Finally clear the call history and print it.

            newPhone.ClearHistory();
            PrintCallHistory(newPhone);
        }
Exemple #4
0
        public void Test()
        {
            Battery bat   = new Battery("1sd34", 500, 100, BatteryType.NiCd);
            Display disp  = new Display();
            GSM     phone = new GSM("6", "IPhone", bat.ToString(), disp.ToString());

            phone.AddCall("12.12.2012", "15:00", "+359 885 635338", 500);
            phone.AddCall("04.04.2004", "12:00", "+359 885 643453", 200);
            phone.AddCall("01.03.2014", "09:00", "+359 884 654634", 100);

            foreach (var item in GSM.CallList)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("Total price of all calls in history: " + phone.CalculateCallPrice(0.37) + "BGN");


            Console.WriteLine("=========================");
            phone.DeleteCall();

            foreach (var item in GSM.CallList)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("Total price of all calls in history: " + phone.CalculateCallPrice(0.37) + "BGN");

            Console.WriteLine("=========================");
            phone.ClearHistory();

            foreach (var item in GSM.CallList)
            {
                Console.WriteLine(item);
            }
        }
Exemple #5
0
        public static void GSMCallHistoryTest()
        {
            GSM oboroten = new GSM("Nokia W8", "Nokia Corp.", 220, "Ivanchoy", new Battery("Zbot", 8, 3, BattertType.Li_Lon), new Display(4.2, 555000));

            oboroten.AddCall(new DateTime(2015, 3, 15), "0893345323", 415);
            oboroten.AddCall(new DateTime(2015, 2, 10), "0881500162", 845);
            oboroten.AddCall(new DateTime(2015, 2, 10), "0875916442", 45);
            oboroten.AddCall(new DateTime(2015, 2, 11), "0891500156", 165);
            oboroten.AddCall(new DateTime(2015, 2, 6), "0891547400", 264);
            oboroten.AddCall(new DateTime(2015, 2, 5), "0881622317", 942);
            oboroten.AddCall(new DateTime(2015, 2, 9), "0879455161", 315);
            oboroten.AddCall(new DateTime(2015, 3, 15), "0893345323", 548); // call again to first number
            //Show calls
            oboroten.ShowCallListHystorY();
            // Total calls

            Console.WriteLine("Total price is: ${0:F2}", oboroten.TotalPrice());
            //Remove the longest call
            uint max   = 0;
            int  index = -1;

            foreach (var item in oboroten.CallsHistory)
            {
                if (item.Duration > max)
                {
                    max   = item.Duration;
                    index = oboroten.CallsHistory.IndexOf(item);
                }
            }
            oboroten.DeleteCallAtPosition(index);
            // Caling again this metod
            oboroten.ShowCallListHystorY();
            Console.WriteLine("After delete max duration call. Total price is: ${0:F2}", oboroten.TotalPrice());

            // Clear the call list
            Console.WriteLine("Delete all calls...");
            oboroten.ClearHystor();
            oboroten.ShowCallListHystorY();
        }
        static void Main()
        {
            Battery firstBattery  = new Battery("A2000", 500, 200, BatteryType.LiIon);
            Battery secondBattery = new Battery("B3000", 600, 300, BatteryType.NiCd);
            Battery thirdBattery  = new Battery("C1000", 400, 100, BatteryType.NiMH);

            Display firstDisplay  = new Display(5, 16000000);
            Display secondDisplay = new Display(4, 16000000);
            Display thirdDisplay  = new Display(4.5, 16000000);

            //// GSM with all parameters

            GSM[] phones = new GSM[]
            {
                GSM.IPhone4S,
                new GSM("Idol 2", "Alcatel", 200, "P.Petrov", firstBattery, firstDisplay),
                new GSM("Galaxy Core 2", "Samsung", 250, "I.Ivanova", secondBattery, thirdDisplay),
                new GSM("P8 lite", "Huawei", 220, "P.Angelov", firstBattery, firstDisplay),
                new GSM("Lumia 800", "Nokia", 300, "A.Tokev", thirdBattery, secondDisplay)
            };

            foreach (var phone in phones)
            {
                Console.WriteLine(phone);
                Console.WriteLine();
            }

            //GSM with some missing parameters

            GSM[] secondPhonesArr = new GSM[]
            {
                new GSM("Idol 2", "Alcatel", 200),
                new GSM("Galaxy Core 2", "Samsung", null, "I.Ivanova"),
                new GSM("P8 lite", "Huawei", 220, "P.Angelov", firstBattery, firstDisplay),
                new GSM("Lumia 800", "Nokia", 300, "A.Tokev", thirdBattery, secondDisplay)
            };

            foreach (var phone in secondPhonesArr)
            {
                Console.WriteLine(phone);
                Console.WriteLine();
            }

            // Call history Tests

            GSM somePhone = new GSM("3310", "Nokia");

            somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888123456", 45));
            somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888111111", 15));
            somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888222222", 55));
            somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888333333", 65));
            somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888444444", 110));
            somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888555555", 20));
            somePhone.AddCall(new Call(new DateTime(2005, 12, 24), "0888666666", 40));

            Console.WriteLine(somePhone.ShowCallHistory());
            Console.WriteLine(somePhone.CallsPrice(0.37));
            Console.WriteLine();

            somePhone.RemoveCall(5);

            Console.WriteLine(somePhone.ShowCallHistory());
            Console.WriteLine(somePhone.CallsPrice(0.37));
            Console.WriteLine();

            somePhone.ClearCallHistory();
            Console.WriteLine(somePhone.ShowCallHistory());
        }