Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reject letter input without row number #38

Merged
merged 1 commit into from
Mar 11, 2025

Conversation

EricccTaiwan
Copy link
Contributor

@EricccTaiwan EricccTaiwan commented Mar 11, 2025

This patch improves input validation by ensuring that a letter input must be followed by a row number. If the user enters only a letter within the valid board range without a corresponding row number, an error message is displayed. This enhances clarity and prevents invalid moves, ensuring correct input handling.

Before

$ ./ttt
 1 |             
 2 |             
 3 |             
 4 |             
---+-------------
      A  B  C  D
X> 1
Invalid operation: No leading alphabet
X> 2
Invalid operation: No leading alphabet
X> a
X> b
X> c
X> d
X> e
Invalid operation: index exceeds board size
X> ^C
$

After

$ ./ttt
 1 |             
 2 |             
 3 |             
 4 |             
---+-------------
      A  B  C  D
X> 1
Invalid operation: No leading alphabet
X> 2
Invalid operation: No leading alphabet
X> a
Invalid operation: No row number
X> b
Invalid operation: No row number
X> c
Invalid operation: No row number
X> d
Invalid operation: No row number
X> e
Invalid operation: index exceeds board size
X> f
Invalid operation: index exceeds board size
X> ^C
$

Copy link
Owner

@jserv jserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of "trailing number," use "row numbers" for precise naming.

@jserv
Copy link
Owner

jserv commented Mar 11, 2025

The term "row numbers" is clearer and more standard, ensuring that the input includes both the row (number) and the column (alphabet).

@EricccTaiwan
Copy link
Contributor Author

EricccTaiwan commented Mar 11, 2025

Thanks for your feedback! "row numbers" sounds clearer, but since only one row number is entered at a time, should it be singular ("row number") instead?

@jserv
Copy link
Owner

jserv commented Mar 11, 2025

Thanks for your feedback! "row numbers" sounds clearer, but since only one row number is entered at a time, should it be singular ("row number") instead?

The term "row numbers" means the collection of the numbers in row, and you should use the form "row number" for each input.

This patch improves input validation by ensuring that a letter input
must be followed by a row number. If the user enters only a letter
within the valid board range without a corresponding row number, an
error message is displayed. This enhances clarity and prevents invalid
moves, ensuring correct input handling.

Co-authored-by: charliechiou <[email protected]>
@EricccTaiwan EricccTaiwan changed the title Reject letter input without trailing number Reject letter input without row number Mar 11, 2025
@jserv jserv merged commit 05f26f5 into jserv:main Mar 11, 2025
@jserv
Copy link
Owner

jserv commented Mar 11, 2025

Thank @EricccTaiwan for contributing!

@EricccTaiwan EricccTaiwan deleted the fix-error-output branch March 11, 2025 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants