Exemplo n.º 1
0
        public void Run()
        {
            var ui = new UI();
            var exercise01 = new Exercise_01();
            var exercise02 = new Exercise_02();
            var exercise03 = new Exercise_03();
            var exercise04 = new Exercise_04();

            var welcome = ui.TopHashOut(
                "WELCOME TO MY LECTURE 42 EXERCISES", 
                "PLEASE MAKE A SELECTION USING THE NUMBERS 1 - 4") +
                ui.NewLineOut(15, "[MAKE A SELECTION]\n") +
                string.Format("1 --> {0}\n2 --> {1}\n3 --> {2}\n4 --> {3}", (Exercises)1, (Exercises)2, (Exercises)3, (Exercises)4
                );
           
            var inputString = " ";

            var selection = 0;

            Console.WriteLine(welcome);
            inputString = Console.ReadLine();
            selection = Convert.ToInt16(inputString);

            var launchOutput = ui.NewLineOut(12, string.Format("\t......LAUNCHING APPLICATION: {0}", (Exercises)selection));

            switch ((Exercises)selection)
            {
                case Exercises.EXERCISE_01:
                    ui.ShowOutput(launchOutput);
                    exercise01.Run();
                    break;
                case Exercises.EXERCISE_02:
                    ui.ShowOutput(launchOutput);
                    exercise02.Run();
                    break;
                case Exercises.EXERCISE_03:
                    ui.ShowOutput(launchOutput);
                    exercise03.Run();
                    break;
                case Exercises.EXERCISE_04:
                    ui.ShowOutput(launchOutput);
                    exercise04.Run();
                    break;
                default:
                    ui.ShowOutput(ui.MiddleHashOut("GOODBYE"));
                    Console.Clear();
                    break;
            }
        }  
Exemplo n.º 2
0
        public void Run()
        {
            var menu = new Menu();
            var ui = new UI(); 

            var welcome = ui.TopHashOut(
                "WELCOME TO MY EXERCISE_02 ATTEMPT",
                "ENTER TWO NUMBERS BETWEEN 1 - 10", 
                "THE APPLICATION WILL OUTPUT THE LARGEST OF THE TWO"
                );

            var inputPrompt = ui.NewLineOut(23, "[ENTER A NUMBER BETWEEN 1 - 10]");
            var menuReturn = ui.MiddleHashOut("RETURNING TO MAIN MENU");
            var firstNumInput = " ";
            var secondNumInput = " ";

            var firstNumber = 0;
            var secondNumber = 0;
            var largestNumber = 0;

            ui.ShowOutput(welcome);
            Console.WriteLine(inputPrompt);
            firstNumInput = Console.ReadLine();
            firstNumber = Convert.ToInt16(firstNumInput);
            Console.Clear();
            Console.WriteLine(inputPrompt);
            secondNumInput = Console.ReadLine();
            secondNumber = Convert.ToInt16(secondNumInput);

            largestNumber = (firstNumber > secondNumber) ? firstNumber : (secondNumber > firstNumber) ? secondNumber : 0;

            var largestOutput = ui.MiddleHashOut(string.Format("THE LARGER NUMBER IS: {0}", largestNumber));
            var equalOutput = ui.MiddleHashOut(string.Format("{0} AND {1} ARE EQUAL", firstNumber, secondNumber));

            if (largestNumber != 0)
            {
                ui.ShowOutput(largestOutput);
                ui.ShowOutput(menuReturn);
                menu.Run();
            }
            else
            {
                ui.ShowOutput(equalOutput);
                ui.ShowOutput(menuReturn);
                menu.Run();
            }
        }
Exemplo n.º 3
0
        public void Run()
        {
            var menu = new Menu();
            var ui = new UI();

            var welcome = ui.TopHashOut(
                "WELCOME TO MY EXERCISE_03 ATTEMPT",
                "ENTER A WIDTH AND A HEIGHT",
                "THE APPLICATION WILL DETERMINE IF THE IMAGE IS IN PORTRAIT OR LANDSCAPE"
                );

            var widthInputPrompt = ui.NewLineOut(23, "[ENTER A WIDTH]");
            var heightInputPrompt = ui.NewLineOut(23, "[ENTER A HEIGHT]");
            var menuReturn = ui.MiddleHashOut("RETURNING TO MAIN MENU");
            var widthInput = " ";
            var heightInput = " ";

            var widthNumber = 0;
            var heightNumber = 0;

            var isPortrait = false;

            ui.ShowOutput(welcome);
            Console.WriteLine(widthInputPrompt);
            widthInput = Console.ReadLine();
            widthNumber = Convert.ToInt16(widthInput);
            Console.Clear();
            Console.WriteLine(heightInputPrompt);
            heightInput = Console.ReadLine();
            heightNumber = Convert.ToInt16(heightInput);

            isPortrait = (heightNumber > widthNumber) ? true : false;

            if (isPortrait)
            {
                ui.ShowOutput(ui.MiddleHashOut("THE IMAGE IS IN PORTRAIT FORMAT"));
                ui.ShowOutput(menuReturn);
                menu.Run();
            }
            else
            {
                ui.ShowOutput(ui.MiddleHashOut("THE IMAGE IS IN LANDSCAPE FORMAT"));
                ui.ShowOutput(menuReturn);
                menu.Run();
            }
        }
Exemplo n.º 4
0
        public void Run()
        {
            var menu = new Menu();
            var ui = new UI();

            var welcome = ui.TopHashOut(
                "WELCOME TO MY EXERCISE_01 ATTEMPT",
                "ENTER A NUMBER BETWEEN 1 - 10", 
                "THE APPLICATION WILL VERIFY THE NUMBER IS IN RANGE") +
                 ui.NewLineOut(18, "[ENTER A NUMBER]");

            var valid = ui.MiddleHashOut("VALID NUMBER");
            var invalid = ui.MiddleHashOut("INVALID NUMBER");
            var menuReturn = ui.MiddleHashOut("RETURNING TO MAIN MENU");
            var inputString = " ";

            var userNumber = 0;

            Console.Clear();
            Console.WriteLine(welcome);
            inputString = Console.ReadLine();
            userNumber = Convert.ToInt16(inputString);

            if (userNumber >= 1 && userNumber <= 10)
            {
                ui.ShowOutput(valid);
                ui.ShowOutput(menuReturn);
                menu.Run();
            }
            else
            {
                ui.ShowOutput(invalid);
                ui.ShowOutput(menuReturn);
                menu.Run();
            }
        }
Exemplo n.º 5
0
        public void Run()
        {
            var menu = new Menu();
            var ui = new UI();

            var welcome = ui.TopHashOut(
                "WELCOME TO MY EXERCISE_04 ATTEMPT", 
                "ENTER A SPEED LIMIT AND A VEHICLE SPEED", 
                "THE APPLICATION WILL DETERMINE WETHER A DEMERIT IS WARRANTED"
                );

            var speedLimitPrompt = ui.NewLineOut(23, "[ENTER A SPEED LIMIT]");
            var vehicleSpeedPrompt = ui.NewLineOut(23, "[ENTER A VEHICLE SPEED]");
            var menuReturn = ui.MiddleHashOut("RETURNING TO MAIN MENU");
            var invalidOutput = ui.MiddleHashOut("SOMETHING WENT WRONG");
            var speedLimitInput = " ";
            var vehicleSpeedInput = " ";

            var speedLimitNumber = 0;
            var vehicleSpeedNumber = 0;
            var demeritLevel = -1;
            var demeritValue = 0;

            ui.ShowOutput(welcome);
            Console.WriteLine(speedLimitPrompt);
            speedLimitInput = Console.ReadLine();
            speedLimitNumber = Convert.ToInt16(speedLimitInput);
            Console.Clear();
            Console.WriteLine(vehicleSpeedPrompt);
            vehicleSpeedInput = Console.ReadLine();
            vehicleSpeedNumber = Convert.ToInt16(vehicleSpeedInput);
            
            demeritLevel =
                (vehicleSpeedNumber >=  0 && vehicleSpeedNumber <= (speedLimitNumber +  4)) ?  0 :
                (vehicleSpeedNumber >=  5 && vehicleSpeedNumber <= (speedLimitNumber +  9)) ?  1 :
                (vehicleSpeedNumber >= 10 && vehicleSpeedNumber <= (speedLimitNumber + 14)) ?  2 :
                (vehicleSpeedNumber >= 15 && vehicleSpeedNumber <= (speedLimitNumber + 19)) ?  3 :
                (vehicleSpeedNumber >= 20 && vehicleSpeedNumber <= (speedLimitNumber + 24)) ?  4 :
                (vehicleSpeedNumber >= 25 && vehicleSpeedNumber <= (speedLimitNumber + 29)) ?  5 :
                (vehicleSpeedNumber >= 30 && vehicleSpeedNumber <= (speedLimitNumber + 34)) ?  6 :
                (vehicleSpeedNumber >= 35 && vehicleSpeedNumber <= (speedLimitNumber + 39)) ?  7 :
                (vehicleSpeedNumber >= 40 && vehicleSpeedNumber <= (speedLimitNumber + 44)) ?  8 :
                (vehicleSpeedNumber >= 45 && vehicleSpeedNumber <= (speedLimitNumber + 49)) ?  9 :
                (vehicleSpeedNumber >= 50 && vehicleSpeedNumber <= (speedLimitNumber + 54)) ? 10 :
                (vehicleSpeedNumber >= 55 && vehicleSpeedNumber <= (speedLimitNumber + 59)) ? 11 :
                (vehicleSpeedNumber  > 60) ? 12 : -1;

            demeritValue = demeritLevel;

            var underLimitOutput = ui.MiddleHashOut(string.Format("YOUR SPEED: {0} - THANK YOU FOR OBEYING THE LAW!", vehicleSpeedNumber));
            var demeritOutput = ui.MiddleHashOut(string.Format("YOUR SPEED: {0} - A DEMERIT OF: {1} WAS ISSUED", vehicleSpeedNumber, demeritValue));
            var suspensionOutput = ui.MiddleHashOut(string.Format("YOUR SPEED: {0} - YOUR LICENSE HAS BEEN SUSPENDED!", vehicleSpeedNumber));

            switch (demeritLevel)
            {
                case 0:
                    ui.ShowOutput(underLimitOutput);
                    ui.ShowOutput(menuReturn);
                    menu.Run();
                    break;
                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                case 6:
                case 7:
                case 8:
                case 9:
                case 10:
                case 11:
                    ui.ShowOutput(demeritOutput);
                    ui.ShowOutput(menuReturn);
                    menu.Run();
                    break;
                case 12:
                    ui.ShowOutput(suspensionOutput); 
                    ui.ShowOutput(menuReturn);
                    menu.Run();
                    break;
                default:
                    ui.ShowOutput(invalidOutput);
                    ui.ShowOutput(menuReturn);
                    menu.Run();
                    break;
            }
        }