Skip to content

Conversation

@EricccTaiwan
Copy link
Contributor

@EricccTaiwan EricccTaiwan commented Mar 12, 2025

This update adds validation to reject row number 0, which was previously allowed. While row numbers exceeding BOARD_SIZE were already handled, there was no explicit check for 0. An error is now triggered when 0 is entered.

Before

$ ./ttt
 1 |             
 2 |             
 3 |             
 4 |             
---+-------------
      A  B  C  D
X> a0
X> b0
X> a5
Invalid operation: index exceeds board size
X> ^C
$

After

$ ./ttt
 1 |             
 2 |             
 3 |             
 4 |             
---+-------------
      A  B  C  D
X> a0
Invalid operation: index cannot be 0
X> b0
Invalid operation: index cannot be 0
X> a5
Invalid operation: index exceeds board size
X> ^C
$ 

This update adds validation to reject row number 0, which was
previously allowed. While row numbers exceeding BOARD_SIZE were
already handled, there was no explicit check for 0. An error is now
triggered when 0 is entered.

Co-authored-by: charliechiou <charlie910417@gmail.com>
@EricccTaiwan
Copy link
Contributor Author

EricccTaiwan commented Mar 12, 2025

This update adds validation to reject row number 0, which was previously allowed. While row numbers exceeding BOARD_SIZE were already handled, there was no explicit check for 0. An error is now triggered when 0 is entered.

I also wanted to ask whether it would be better to use a single error message for both row number 0 and values exceeding BOARD_SIZE, rather than handling them separately.

@jserv jserv merged commit e8eade4 into jserv:main Mar 16, 2025
2 checks passed
@jserv
Copy link
Owner

jserv commented Mar 16, 2025

Thank @EricccTaiwan for contributing!

@EricccTaiwan EricccTaiwan deleted the fix-row-zero branch March 16, 2025 12:55
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.

2 participants