コード例 #1
0
ファイル: Program.cs プロジェクト: lemonclik/C-API
 static void Main(string[] args)
 {
     Console.WriteLine("hello World!");
     stringUtility.StringLibrary clsString = new stringUtility.StringLibrary();
     Console.WriteLine(clsString.StartsWithUpper("kts"));
     Console.WriteLine(clsString.IsStringPalindrome("12321"));
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: ColtonG5/GuessingGame
        static void Operation(string u)
        {
            Console.WriteLine("What do you want to check? (1 for palindrome, 2 for uppercase)");

            string s = Console.ReadLine();

            switch (s)
            {
            case "1":

                if (clsString.IsStringPalindrome(u))
                {
                    Console.WriteLine("The string is a Palindrome");
                }
                else
                {
                    Console.WriteLine("The string is not a Palindrome");
                }
                break;

            case "2":

                if (clsString.StartsWithUpper(u))
                {
                    Console.WriteLine("The string starts with an uppercase");
                }
                else
                {
                    Console.WriteLine("The string does not start with an uppercase");
                }
                break;
            }
        }
コード例 #3
0
        static void ChooseOption()
        {
            //ChooseOption stays under ChooseString to ensure there is an output for what the user typed
            //ChooseOption sets a variable called end to false then runs a while loop until an event triggers end to true
            string choice = ChooseString();
            bool   end    = false;

            while (!end)
            {
                //Clears the console from annoying lines and creates a menu that the user can respond to by typing 1 or 2 then reads the user input
                Console.Clear();
                Console.WriteLine("\nWould you like to check if \n\"" + choice + "\" is:\n\n1) Starts With a Uppercase\n\n2) Palindrome");
                switch (Console.ReadLine())
                {
                //Case Uppercase: ends the while loop, clears the console, writes a message if the message is uppercase and a different one if it detects anything else, such as a number
                case "1":
                    end = true;
                    Console.Clear();
                    if (clsString.StartsWithUpper(choice))
                    {
                        Console.WriteLine("It does start with a Uppercase");
                    }
                    else
                    {
                        Console.WriteLine("It does not start with a Uppercase");
                    }
                    Exit();
                    break;

                //Case Palindrome: ends the while loop, clears the console, in the other file Josh helped me to reverse the user input and it does a check if the reversed input is the same as the original, then says it is or says it isnt if it detects anything else
                case "2":
                    end = true;
                    Console.Clear();
                    if (clsString.IsStringPalindrome(choice))
                    {
                        Console.WriteLine("It is palindrome\n");
                    }
                    else
                    {
                        Console.WriteLine("It is not palindrome\n");
                    }
                    //Calls the exit function
                    Exit();
                    break;
                }
            }
        }
コード例 #4
0
 static void Main(string[] args)
 {
     stringUtility.StringLibrary clsString = new stringUtility.StringLibrary();
     Console.WriteLine(clsString.StartsWithUpper("sts"));
     Console.WriteLine(clsString.IsStringPalindrome("sts"));
 }