Rank
The Rank class represents a row on a chessboard, ranging from 1 to 8. It provides methods for manipulating and querying rank values, performing arithmetic operations, and validating ranges.
Overview
A rank is represented by an integer (1 to 8).
Provides utility methods for arithmetic operations, comparisons, and range validation.
Arithmetic Operations
Addition: You can add an integer to a rank, resulting in a new rank shifted by the given amount.
Subtraction: You can subtract an integer from a rank, resulting in a new rank shifted by the given amount.
These operations are useful for calculating neighboring ranks or iterating over ranks programmatically.
Example Usage
val rank = Rank(5)
val nextRank = rank + 1 // Rank(6)
val isEqual = rank.isEqualTo(5) // trueContent copied to clipboard