06.HighQualityMethodsHomework/RefactorCSharpPart2Exam/11. CSharp-Part-2-Exam/CSharp-Part-2-Exam/CATaclysm/CATaclysm.cs
/// <summary>
/// Checks if the current token is valid
/// </summary>
/// <param name="token">Token to check</param>
/// <param name="beforeIndex">Before which index</param>
/// <param name="afterIndex">After which index</param>
/// <returns>True or false</returns>
Checks if the current token is valid
Checks if the current token is valid
private static bool CheckValidityOfToken(string token, int beforeIndex, int afterIndex)
        {
            if (beforeIndex < 0 && afterIndex >= token.Length)
            {
                return true;
            }
            if (beforeIndex < 0 && (!char.IsLetter(token[afterIndex]) || token[afterIndex] == '?' || token[afterIndex] == ','))
            {
                return true;
            }
            if (afterIndex >= token.Length && (!char.IsLetter(token[beforeIndex]) || token[beforeIndex] == '('))
            {
                return true;
            }
            if ((!char.IsLetter(token[beforeIndex]) || token[beforeIndex] == '(') && (!char.IsLetter(token[afterIndex]) || token[afterIndex] == '?' || token[afterIndex] == ','))
            {
                return true;
            }
            return false;
        }
private static bool CheckValidityOfToken ( string token , int beforeIndex , int afterIndex ) { if ( beforeIndex < 0 && afterIndex >= token . Length ) { return true ; } if ( beforeIndex < 0 && ( ! char . IsLetter ( token [ afterIndex ] ) || token [ afterIndex ] == ' ' || token [ afterIndex ] == ' ' ) ) { return true ; } if ( afterIndex >= token . Length && ( ! char . IsLetter ( token [ beforeIndex ] ) || token [ beforeIndex ] == ' ' ) ) { return true ; } if ( ( ! char . IsLetter ( token [ beforeIndex ] ) || token [ beforeIndex ] == ' ' ) && ( ! char . IsLetter ( token [ afterIndex ] ) || token [ afterIndex ] == ' ' || token [ afterIndex ] == ' ' ) ) { return true ; } return false ; }
Checks if the current token is valid
Checks if the current token is valid
True or false
True or false
token
string
Token to check
Token to check
beforeIndex
int
Before which index
Before which index
afterIndex
int
After which index
After which index