Cute Chess  0.1
Public Types | Public Member Functions | List of all members
Chess::Square Class Reference

A generic chess square type consisting of a file and a rank. More...

#include <square.h>

Public Types

enum  Color { Light, Dark, NoColor }
 

Public Member Functions

Color color () const
 
int file () const
 
bool isValid () const
 
bool operator!= (const Square &other) const
 
bool operator== (const Square &other) const
 
int rank () const
 
void setFile (int file)
 
void setRank (int rank)
 
 Square ()
 
 Square (int file, int rank)
 

Detailed Description

A generic chess square type consisting of a file and a rank.

Square is mainly used as a middle-layer between the Board class (which uses integers for squares) and more generic, high-level classes like GenericMove.

Member Enumeration Documentation

Square color

Enumerator
Light 

Light-colored square.

Dark 

Dark-colored square.

NoColor 

Color for invalid squares.

Constructor & Destructor Documentation

Chess::Square::Square ( )

Creates a new square with invalid defaults.

Chess::Square::Square ( int  file,
int  rank 
)

Creates a new square from file and rank.

Member Function Documentation

Square::Color Chess::Square::color ( ) const

Returns the color of the square.

int Chess::Square::file ( ) const

Zero-based file of the square. 0 is the 'a' file.

bool Chess::Square::isValid ( ) const

Returns true if both file and rank have non-negative values.

bool Chess::Square::operator!= ( const Square other) const

Returns true if other is different from this square.

bool Chess::Square::operator== ( const Square other) const

Returns true if other is the same as this square.

int Chess::Square::rank ( ) const

Zero-based rank of the square. 0 is white's first rank.

void Chess::Square::setFile ( int  file)

Sets the file to file.

void Chess::Square::setRank ( int  rank)

Sets the rank to rank.


The documentation for this class was generated from the following files: