File
The File class represents a column on a chessboard, ranging from 'a' to 'h'. It provides methods for manipulating and querying file values, converting them to array indices, and performing arithmetic operations.
Overview
A file is represented by a single character ('a' to 'h').
Provides utility methods for arithmetic operations, comparisons, and conversions.
Arithmetic Operations
Addition: You can add an integer to a file, resulting in a new file shifted by the given amount.
Subtraction: You can subtract an integer from a file, resulting in a new file shifted by the given amount.
These operations are useful for calculating neighboring files or iterating over files programmatically.
Conversion
To Array Index: The toArrayIndex method converts the file to a zero-based index (0 for 'a', 7 for 'h').
This is useful for accessing arrays or lists that represent chessboard rows or columns.
Example Usage
val file = File('e')
val nextFile = file + 1 // File('f')
val index = file.toArrayIndex() // 4
val isEqual = file.isEqualTo('e') // true