示例#1
0
        private static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("Select chapter\n" +
                                  "1. Variables\n" +
                                  "2. MIT Introduction to algorithms\n" +
                                  "3. Console\n" +
                                  "4. Loop\n" +
                                  "5. Arrays\n" +
                                  "6. Numeral Systems");

                string selector = Console.ReadLine();

                switch (selector)
                {
                case "0":
                    ConsoleOutput.Title("Scratchpad");
                    TestScratchpad.DoScratchpad();
                    break;

                case "1":
                    ConsoleOutput.Title("Variables exercises");
                    VariableExercises.DoVariableExercises();
                    break;

                case "2":
                    MITAlgorithmsIntroduction.Exercises();
                    break;

                case "3":
                    ConsoleOutput.Title("Console Exercises");
                    ConsoleExercises.DoExercises();
                    break;

                case "4":
                    ConsoleOutput.Title("Loops exercises");
                    LoopsExercises.DoExercises();
                    break;

                case "5":
                    ConsoleOutput.Title("Arrays exercises");
                    ArraysExercises.DoExercises();
                    break;

                default:
                    break;
                }

                Console.WriteLine("============chapter==finished==========" + Environment.NewLine);
            }
        }
示例#2
0
        // Asks and returns full name in 2 strings
        private static void NameRobot(out string firstName, out string lastName)
        {
            firstName = lastName = null;
            string[] userInputSplit;

            while (true)
            {
                Console.WriteLine("What is your name? (first name before last name)");
                string userInput = Console.ReadLine();
                userInputSplit = userInput.Split(new char[] { ' ' });
                if (userInputSplit[0] != "")
                {
                    break;
                }
            }

            for (int i = 0; i < userInputSplit.Length; i++)
            {
                if (firstName == null)
                {
                    firstName = userInputSplit[i];
                }
                else if (lastName == null)
                {
                    lastName = userInputSplit[i];
                }
                else
                {
                    lastName = String.Concat(lastName, " ", userInputSplit[i]);
                }
            }

            firstName = VariableExercises.CapitalizeFirstLetters(firstName);
            lastName  = VariableExercises.CapitalizeFirstLetters(lastName);

            //Console.WriteLine ("Your first name is: " + firstName + Environment.NewLine + "Your last name is: " + lastName);
        }