コード例 #1
0
        static void Main()
        {
            GSM firstTest  = new GSM("Desire 500", "HTC", 500, "Stamat Peshov");
            GSM secondTest = new GSM("A3", "Samsmung", 350, "Dimitar Stoyanov");
            GSM thirdTest  = new GSM("One Mini", "HTC", 800, "Strinka Krustanova");

            // Test Battery
            firstTest.BatteryCharacteristics = new Battery("Li-lon");
            //Console.WriteLine(firstTest.BatteryCharacteristics.Model);

            // Test Display
            firstTest.DisplayCharacteristics = new Display("500 X 500", 3);
            //Console.WriteLine(firstTest.DisplayCharacteristics.Size);

            // Test GSM
            GSMTest tst = new GSMTest();

            tst.gsmTest.Add(firstTest);
            tst.gsmTest.Add(secondTest);
            tst.gsmTest.Add(thirdTest);

            tst.gsmTest[0].SeeAllGSMInformation(); // work
            tst.gsmTest[1].SeeAllGSMInformation(); // work
            tst.gsmTest[2].SeeAllGSMInformation(); // work
                                                   // Console.WriteLine(tst.gsmTest[0].IPhone4S = "Apple");

            // Test call history

            GSMCallHistoryTest testCalls = new GSMCallHistoryTest("One", "HTC");

            testCalls.TestFunctionality();
        }
コード例 #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();
        }
コード例 #5
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();
        }
コード例 #6
0
        public void Start()
        {
            GSM[] Phones = new GSM[3];
            Phones[0] = new GSM("Safari", "Antilop", 20, "Kapitan Skrutz", 3, 5, BatteryType.LiIon, 480, 1);
            Phones[1] = new GSM("GalaxyJ5", "Samsung", 300, "Stoyan", 80, 24, BatteryType.LiIon, 1600, 3);
            Phones[2] = new GSM("Note8", "Samsung", 700, "Atanas", 120, 53, BatteryType.NiMH, 2120, 4);
            foreach (GSM phone in Phones)
            {
                Console.WriteLine(phone.ToString());
                Console.WriteLine();
            }

            Console.WriteLine(GSM.IPhone4S.ToString());
        }
コード例 #7
0
        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}.");
        }
コード例 #8
0
        //Create an array of few instances of the GSM class.
        public static void TestTheGSMs()
        {
            GSM Samsung = new GSM("Galaxy", "Samsung", "John", 30, new Battery("233DS", 900, 700, BatteryType.LiIon), new Display(18, 78000));

            GSM HTC = new GSM("One", "HTC", "Kiro", 20, new Battery("909DS", 980, 780, BatteryType.NiCd), new Display(14, 65000));

            GSM Sony = new GSM("Xperia", "Sony", "Mira", 28, new Battery("213SXZ", 700, 600, BatteryType.NiMH), new Display(19, 99000));

            GSM[] gsms = new GSM[] { Samsung, HTC, Sony, GSM.GetIPhone4s };
            foreach (GSM gsm in gsms)
            {
                gsm.PrintGSMInfo();
            }
        }
コード例 #9
0
ファイル: GSMTest.cs プロジェクト: plwh/TelerikHomework
        public static void GSMTestClass()
        {
            GSM firstPhone = new GSM("Galaxy S4","Samsung",1000,"Pesho",new Battery("Standard", 370,17,BatteryTypes.LiIon),new Display(5,16000000),new List<Call>());
            GSM secondPhone = new GSM("Redmi 1S", "Xiaomi", 300, "Gosho", new Battery("BM41"), new Display(4.7, 16000000), new List<Call>());
            GSM thirdPhone = new GSM("Moto G", "Motorola", 400, "John", new Battery("Unknown", 336, 24, BatteryTypes.LiIon), new Display(4.5, 16000000), new List<Call>());

            GSM[] phones = new GSM[]{firstPhone,secondPhone,thirdPhone};

            for (int i = 0; i < phones.Length; i++)
            {
                Console.WriteLine("Information about phone №{0}\n", i + 1);
                Console.WriteLine(phones[i]+"\n");
            }
            Console.WriteLine("Information about IPhone4S\n");
            Console.WriteLine(GSM.IPhone4S);
        }
コード例 #10
0
        public static void TestGSMClass()
        {
            GSM[] testArray = new GSM[] {
                new GSM("HD7", "HTC"),
                new GSM("3310", "Nokia", 1, "Pesho"),
                new GSM("A536", "Lenovo", 250, "Me", new Battery("Some battery model", 24, 6), new Display(5, 16000000))
            };

            Console.WriteLine("******************************");
            foreach (GSM gsm in testArray)
            {
                Console.WriteLine(gsm.ToString());
                Console.WriteLine("******************************");
            }

            Console.WriteLine(GSM.IPhone4S.ToString());
        }
コード例 #11
0
        public static void Tester()
        {
            GSM gsm1 = new GSM("Lumia", "Nokia");
            GSM gsm2 = new GSM("Galaxy", "Samsung", "Ivo", 506.32,
                                new Battery("qqq", 12.5, 15.3, BatteryType.LiIon),
                                new Display(15.1, 16000));
            GSM gsm3 = new GSM("Asha", "Nokia", "Ina", 201.1);
            GSM gsm4 = new GSM("Exp", "Sony", price: 506.32, display: new Display(17.1));
            GSM[] phones = { gsm1, gsm2, gsm3, gsm4 };

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

            Console.WriteLine(GSM.IPhone4S);
        }
コード例 #12
0
        private static void GSMTest()
        {
            GSM[] phones = new GSM[4];

            phones[0] = new GSM("Samsung", "S6 Edge", 700, "Nikolai Kostov", new Battery("13/33335/UA8G", 200, 15, BatteryType.LiIon), new Display(5.5, 16));
            phones[1] = new GSM("LG", "G Flex", 500, "Milen Kamburov", new Battery("2244/44U6/KKLI8", 190, 19, BatteryType.LiIon), new Display(6.0, 16));
            phones[2] = new GSM("Motorola", "Nexus 6", 600, "Asen Dermenjiev", new Battery("0093/478AS/9IOF1", 240, 17, BatteryType.NiCd), new Display(6.3, 16));

            phones[3] = GSM.Iphone4S;

            Console.WriteLine("-------------------------------------------------------");
            foreach (var phone in phones)
            {
                Console.WriteLine(phone.ToString());
                Console.ResetColor();
                Console.WriteLine("-------------------------------------------------------");
            }
        }
コード例 #13
0
        private static void GSMTest()
        {
            GSM[] phones = new GSM[4];

            phones[0] = new GSM("Samsung", "S6 Edge", 700, "Nikolai Kostov", new Battery("13/33335/UA8G", 200, 15, BatteryType.LiIon), new Display(5.5, 16));
            phones[1] = new GSM("LG", "G Flex", 500, "Milen Kamburov", new Battery("2244/44U6/KKLI8", 190, 19, BatteryType.LiIon), new Display(6.0, 16));
            phones[2] = new GSM("Motorola", "Nexus 6", 600, "Asen Dermenjiev", new Battery("0093/478AS/9IOF1", 240, 17, BatteryType.NiCd), new Display(6.3, 16));

            phones[3] = GSM.Iphone4S;

            Console.WriteLine("-------------------------------------------------------");
            foreach (var phone in phones)
            {
                Console.WriteLine(phone.ToString());
                Console.ResetColor();
                Console.WriteLine("-------------------------------------------------------");
            }
        }
コード例 #14
0
        public static void TestGSMClasses()
        {
            GSM[] gsms = new GSM[1];
            for (uint i = 0; i < gsms.Length; i++)
            {
                gsms[i] = new GSM($"Model-{i + 1}", $"Proizvoditel-{i + 1}", (30 + (i + 1) * 10), $"MyOwner{i + 1}",
                                  new Battery("mod", 24, 8, Battery.BatteryType.LiIon), new Display(5, 225));

                Console.WriteLine(gsms[i]);
                Console.WriteLine();

                for (uint j = 0; j < 5; j++)
                {
                    gsms[i].AddCall(new Call("2017/11/25", "23:55:25", "0888 333 066", 35 + j));

                    Console.WriteLine(gsms[i].CallHistory[(int)j]);
                    Console.WriteLine();
                }
                Console.WriteLine(new String('-', 80));

                //gsms[i].ClearCallHistory();
                //Console.WriteLine("Number of calls: " + gsms[i].CallHistory.Count);

                //for (int k = 1; k < 5; k+=2)
                //{
                //    gsms[i].DeleteCall(gsms[i].CallHistory[k]);
                //}

                //Console.WriteLine(new String('-', 80));
                //Console.WriteLine(new String('-', 80));
                //foreach (var call in gsms[i].CallHistory)
                //{
                //    Console.WriteLine(call);
                //}

                Console.WriteLine(gsms[i].TotalPriceOfCalls());
                Console.WriteLine(gsms[i].TPofCallsWithoutLongestCall());
            }

            Console.WriteLine();
            Console.WriteLine(GSM.IPhone4S);
        }
コード例 #15
0
        // Task 07 - the GSM Test

        public GSMTest()
        {
            GSM[]    gsmArr        = new GSM[5];
            string[] models        = { "HTC", "Samsung", "LG", "Nokia", "KucheMobile" };
            int[]    prices        = { 120, 340, 505, 620, 1100 };
            string[] owners        = { "Messi", "Ronaldo", "Berbatov", "Skartel", "Hulk" };
            string[] manifacturers = { "China", "USA", "Japan", "France", "UK" };

            for (int i = 0; i < gsmArr.Length; i++)
            {
                gsmArr[i] = new GSM(models[i], manifacturers[i], prices[i], owners[i]);
                Console.WriteLine("Print with the overrided To String() method:");
                Console.WriteLine(gsmArr[i]);
                Console.WriteLine();
            }

            Console.WriteLine(GSM.IPhone4S.Model);

            Console.WriteLine(GSM.IPhone4S.Manufacturer);
        }
コード例 #16
0
        public static void CallHistoryTest()
        {
            const decimal pricePerMinute = 0.37M;

            GSM myGSM = new GSM("123", "test");
            Call call1 = new Call(DateTime.Parse("21.02.2015 15:20:23"), 632, "0889235363");
            Call call2 = new Call(DateTime.Parse("22.02.2015 01:10:23"), 254, "0887775363");
            Call call3 = new Call(DateTime.Parse("23.02.2015 18:20:23"), 954, "0878787800");

            myGSM.AddCalls(call1);
            myGSM.AddCalls(call2);
            myGSM.AddCalls(call3);

            for (int i = 0; i < myGSM.CallHistory.Count; i++)
            {
                Console.WriteLine(myGSM.CallHistory[i]);
            }

            Console.WriteLine("Total price of the calls in the history = {0:F2}",
                               myGSM.PriceOfCalls(pricePerMinute));

            Call maxCall = new Call();
            for (int i = 0; i < myGSM.CallHistory.Count; i++)
            {
                if (myGSM.CallHistory[i].Duration > maxCall.Duration)
                {
                    maxCall = myGSM.CallHistory[i];
                }
            }
            myGSM.DeleteCalls(maxCall);
            Console.WriteLine("Total price of the calls w/o max call = {0:F2}",
                               myGSM.PriceOfCalls(pricePerMinute));

            myGSM.ClearCallHistory();

            Console.WriteLine("Number of calls after history clear: {0}", myGSM.CallHistory.Count);
        }
コード例 #17
0
 public GSMCallHistoryTest(string model, string manyfacturer)
 {
     testCalls = new GSM(model, manyfacturer);
 }