Exemplo n.º 1
0
        public static void CreateCallHistory()
        {
            GSM testgsm = new GSM();

            Call callOne   = new Call(new DateTime(2015, 02, 03), new DateTime(2015, 02, 03, 14, 05, 25), "private number", 23);
            Call callTwo   = new Call(new DateTime(2015, 02, 03), new DateTime(2015, 02, 03, 17, 14, 38), "private number", 701);
            Call callThree = new Call(new DateTime(2015, 02, 04), new DateTime(2015, 02, 03, 10, 02, 45), "private number", 411);

            //Add few calls
            Console.WriteLine("Added few calls");
            testgsm.CallHistory.Add(callOne);
            testgsm.CallHistory.Add(callTwo);
            testgsm.CallHistory.Add(callThree);



            Console.WriteLine("Info" + new string('-', 40));
            Console.WriteLine("Initial number of calls: {0}", testgsm.CallHistory.Count);
            Console.WriteLine("Price of the calls: " + testgsm.CalculateCallPrice());
            Console.WriteLine("Longest call: {0}", testgsm.FindLongestCall().Duration);

            Console.WriteLine("\nAdd a new call");
            testgsm.AddCall(new Call(new DateTime(2015, 02, 04), new DateTime(2015, 02, 03, 10, 33, 45), "private number", 806));
            Console.WriteLine("Info" + new string('-', 40));
            Console.WriteLine("Number of calls: {0}", testgsm.CallHistory.Count);
            Console.WriteLine("Price of the calls: " + testgsm.CalculateCallPrice());
            Console.WriteLine("Longest call: {0}", testgsm.FindLongestCall().Duration);

            //Delete longest call
            testgsm.DeleteCall(testgsm.CallHistory.IndexOf(testgsm.FindLongestCall()));
            Console.WriteLine("\nDelete longest call");
            Console.WriteLine("Info" + new string('-', 40));
            Console.WriteLine("Number of calls: {0}", testgsm.CallHistory.Count);
            Console.WriteLine("Price of the calls: " + testgsm.CalculateCallPrice());
            Console.WriteLine("Longest call: {0}", testgsm.FindLongestCall().Duration);

            Console.WriteLine("\nDelete all call history");
            testgsm.DeleteAllHistory();
            Console.WriteLine("Info" + new string('-', 40));
            Console.WriteLine("Number of calls: {0}", testgsm.CallHistory.Count);


            Console.WriteLine(testgsm.CallHistory.Count);
        }
Exemplo n.º 2
0
        public static void Main()
        {
            try
            {
                Display display = new Display(4, 16000000);
                Battery battery = new Battery(620, 8, Battery.BatteryModel.NiMH);
                GSM phone = new GSM("One", "HTC", 850, "Person", battery, display);

                GSMTest test = new GSMTest();
                Console.WriteLine("=============");
                test.GSMTesting();
                Console.WriteLine("=============");

                DateTime time = new DateTime();
                time = DateTime.Now;

                Calls[] call = new Calls[5];

                //making some phone calls
                for (int i = 0; i < 5; i++)
                {
                    time = time.AddDays(i);
                    string phoneNumber = "0888999999";
                    int duration = i + 100;
                    call[i] = new Calls(time, phoneNumber, duration);
                    phone.AddCall(call[i]);
                }

                Console.WriteLine();
                decimal pricePerMinute = 0.37m;

                //display call information
                phone.CallHistory();
                Console.WriteLine("=============");
                phone.TotalPriceOfCalls(pricePerMinute);
                Console.WriteLine("=============");
                phone.FindLongestCall();
                phone.TotalPriceOfCalls(pricePerMinute);
                Console.WriteLine("=============");
                phone.ClearCallHistory();
                phone.CallHistory();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }