Skip to content

Passing "exit" into option 8 of the sub menu does not hit the exit case #40

Description

@rbh92

repro steps:

Launch sub menu
select option 8
Pass "exit"

Expected result: exit case is hit, we break out of the loop
Actual result: "The new model you entered is invalid. The model should be 9 characters long starting with 'CFI-', followed by 4 numbers and a letter." and we cycle through the loop again.

The reason is due to the following set of if statements (line 1338 - 1354 of Program.cs):

if (string.IsNullOrEmpty(newModel))
{
    // The user did not enter a valid string
    System.Console.WriteLine("Please enter a valid model number to continue...");
} else if (newModel.Length < 9)
{
    // The entered model is an invalid length
    System.Console.WriteLine("The new model you entered is invalid. The model should be 9 characters long starting with 'CFI-', followed by 4 numbers and a letter.");
}else if (!newModel.StartsWith("CFI-"))
{
    System.Console.WriteLine("The new model you entered is invalid. The model should be 9 characters long starting with 'CFI-', followed by 4 numbers and a letter.");
}else if (newModel == "exit")
{
    // The user wants to exit this menu
    isDone = true;
    break;
}

the given value "exit" gets caught in the else if (newModel.Length < 9) and never hits the if (newModel == "exit") statement

Fix - move the exit clause above the Length < 9 clause.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions