コード例 #1
0
ファイル: Program.cs プロジェクト: gstaizer/backend
        static void Main(string[] args)
        {
            const string incorrectNumber = "Incorrect number of arguments!", example = "Usage CheckIdentifier.exe <identifier>", emptyInput = "Input is empty",
                         incorrectIndexStr = "incorrect Index ", incorrectCharStr = ", incorrect Char ";

            if (args.Length != 1)
            {
                Console.WriteLine(incorrectNumber);
                Console.WriteLine(example);
                return;
            }

            CheckIdentifierLibrary.CheckIdentifier checkIdentifier = new CheckIdentifierLibrary.CheckIdentifier();
            string identifier = args[0];

            if (checkIdentifier.IsIdentifier(identifier))
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
                if (checkIdentifier.IsEmpty())
                {
                    Console.WriteLine(emptyInput);
                }
                else
                {
                    int incorrectIndex = checkIdentifier.GetIncorrectIndex();
                    Console.WriteLine(incorrectIndexStr + incorrectIndex + incorrectCharStr + "'" + identifier[incorrectIndex] + "'");
                }
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: kelvionald/sem4-backend
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Incorrect number of arguments!");
                Console.WriteLine("Usage CheckIdentifier.exe <identifier>");
                return;
            }
            CheckIdentifierLibrary.CheckIdentifier checkIdentifier = new CheckIdentifierLibrary.CheckIdentifier();
            string identifier = args[0];

            if (checkIdentifier.IsIdentifier(identifier))
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
                if (checkIdentifier.IsEmpty())
                {
                    Console.WriteLine("Input is empty");
                }
                else
                {
                    int badIndex = checkIdentifier.GetBadIndex();
                    Console.WriteLine("Bad index " + badIndex + ", bad char '" + identifier[badIndex] + "'");
                }
            }
        }