Beispiel #1
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);
            }
        }
        static void Main(string[] args)
        {
            GSM gsm = new GSM("HTC One X", "HTC", 799.00, "Vankata", 4.7, 16000000);
            gsm.AddCall(new Call(DateTime.Parse("12.09.2013 15:00:12"), "+359888333555", 122)); // Price for the call = 1.11
            gsm.AddCall(new Call(DateTime.Parse("20.9.2013 17:52:51"), "+359889121223", 54)); // Price for the call = 0.37
            gsm.AddCall(new Call(DateTime.Parse("25.09.2013 8:10:22"), "+359789444222", 180)); // Price for the call = 1.11

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(gsm.CallsInformation());

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("Total price of the calls = {0}", gsm.TotalPriceOfCalls(0.37)); // Total price = 2.59

            int maxDuration = -1;
            int indexMaxDuration = -1;

            for (int i = 0; i < gsm.CallHistory.Count; i++)
            {
                if (gsm.CallHistory[i].Duration > maxDuration)
                {
                    maxDuration = gsm.CallHistory[i].Duration;
                    indexMaxDuration = i;
                }
            }

            gsm.DeleteCall(indexMaxDuration);

            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine("Total price of the calls = {0}", gsm.TotalPriceOfCalls(0.37)); // Total price = 1.48

            gsm.ClearHistory();

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Total price of the calls = {0}", gsm.TotalPriceOfCalls(0.37)); // Total price = 0

            Console.WriteLine();
        }