示例#1
0
        private static void GSMTestMethod()
        {
            GSM phone1 = new GSM(
                "iPhone 4",
                "Apple",
                1000,
                "Pesho",
                new Battery("zzzz", 10, 2, BatteriesEnum.LiIon),
                new Display(12, 222),
                new List <Call>());
            GSM phone2 = new GSM(
                "iPhone 3",
                "Apple",
                500,
                "Gosho",
                new Battery("yyyy", 12, 1, BatteriesEnum.NiCd),
                new Display(14, 224),
                new List <Call>());

            GSM[] allPhones = { phone1, phone2 };
            foreach (var gsm in allPhones)
            {
                Console.WriteLine(gsm);
            }

            Console.WriteLine(GSM.IPhone4S);
        }
        private static void GSMTestMethod()
        {
            GSM phone1 = new GSM(
                "iPhone 4",
                "Apple",
                1000,
                "Pesho",
                new Battery("zzzz", 10, 2, BatteriesEnum.LiIon),
                new Display(12, 222),
                new List<Call>());
            GSM phone2 = new GSM(
                "iPhone 3",
                "Apple",
                500,
                "Gosho",
                new Battery("yyyy", 12, 1, BatteriesEnum.NiCd),
                new Display(14, 224),
                new List<Call>());

            GSM[] allPhones = { phone1, phone2 };
            foreach (var gsm in allPhones)
            {
                Console.WriteLine(gsm);
            }

            Console.WriteLine(GSM.IPhone4S);
        }
示例#3
0
        public static void GSMCallHistoryTestMethod()
        {
            List <Call> newRange = new List <Call>();

            // P12
            GSM phone3 = new GSM(
                "iPhone 4",
                "Apple",
                1200,
                "Doncho",
                new Battery("xxxx", 12, 3, BatteriesEnum.LiIon),
                new Display(12, 222),
                new List <Call>());
            var  date1    = new DateTime(2014, 03, 10, 04, 55, 0);
            var  date2    = new DateTime(2014, 03, 10, 13, 55, 0);
            var  date3    = new DateTime(2014, 03, 10, 18, 55, 0);
            Call newcall1 = new Call(date1, "1234567890", 100);
            Call newcall2 = new Call(date2, "1234567890", 100);
            Call newcall3 = new Call(date3, "1234567890", 100);

            phone3.CallHistory.Add(newcall1);
            phone3.CallHistory.Add(newcall2);
            phone3.CallHistory.Add(newcall3);

            // P12
            phone3.AddCall();
            phone3.RemoveCall(phone3.CallHistory);
            phone3.PrintHistory();
            Console.WriteLine("Enter the price per minute:");
            double multi    = double.Parse(Console.ReadLine());
            double totalSum = phone3.Calculate(multi);

            Console.WriteLine("Total sum for conversations:");
            Console.WriteLine(totalSum);
            int    indexForRemoving    = 0;
            double longestConversation = double.MinValue;

            for (int i = 0; i < phone3.CallHistory.Count; i++)
            {
                if (phone3.CallHistory[i].Duration > longestConversation)
                {
                    indexForRemoving = i;
                }
            }

            Console.WriteLine("Enter record {0} for removing (longest call in the list)", indexForRemoving);
            phone3.RemoveCall(phone3.CallHistory);
            double totalSumRecalc = phone3.Calculate(multi);

            Console.WriteLine("Total sum for conversations after removing the longest call:");
            Console.WriteLine(totalSumRecalc);
            phone3.PrintHistory();
            phone3.ClearAll();
        }
        public static void GSMCallHistoryTestMethod()
        {
            List<Call> newRange = new List<Call>();

            // P12
            GSM phone3 = new GSM(
                "iPhone 4",
                "Apple",
                1200,
                "Doncho",
                new Battery("xxxx", 12, 3, BatteriesEnum.LiIon),
                new Display(12, 222),
                new List<Call>());
                var date1 = new DateTime(2014, 03, 10, 04, 55, 0);
                var date2 = new DateTime(2014, 03, 10, 13, 55, 0);
                var date3 = new DateTime(2014, 03, 10, 18, 55, 0);
            Call newcall1 = new Call(date1, "1234567890", 100);
            Call newcall2 = new Call(date2, "1234567890", 100);
            Call newcall3 = new Call(date3, "1234567890", 100);
            phone3.CallHistory.Add(newcall1);
            phone3.CallHistory.Add(newcall2);
            phone3.CallHistory.Add(newcall3);

            // P12
            phone3.AddCall();
            phone3.RemoveCall(phone3.CallHistory);
            phone3.PrintHistory();
            Console.WriteLine("Enter the price per minute:");
            double multi = double.Parse(Console.ReadLine());
            double totalSum = phone3.Calculate(multi);
            Console.WriteLine("Total sum for conversations:");
            Console.WriteLine(totalSum);
            int indexForRemoving = 0;
            double longestConversation = double.MinValue;
            for (int i = 0; i < phone3.CallHistory.Count; i++)
            {
                if (phone3.CallHistory[i].Duration > longestConversation)
                {
                    indexForRemoving = i;
                }
            }

            Console.WriteLine("Enter record {0} for removing (longest call in the list)", indexForRemoving);
            phone3.RemoveCall(phone3.CallHistory);
            double totalSumRecalc = phone3.Calculate(multi);
            Console.WriteLine("Total sum for conversations after removing the longest call:");
            Console.WriteLine(totalSumRecalc);
            phone3.PrintHistory();
            phone3.ClearAll();
        }