File indexing completed on 2025-03-16 06:57:22
0001 /******************************************************************* 0002 * 0003 * Copyright 2007 Aron Boström <c02ab@efd.lth.se> 0004 * 0005 * Bovo is free software; you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation; either version 2, or (at your option) 0008 * any later version. 0009 * 0010 * Bovo is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with Bovo; see the file COPYING. If not, write to 0017 * the Free Software Foundation, 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 * 0020 ********************************************************************/ 0021 0022 #ifndef BOVO_SQUARE_H 0023 #define BOVO_SQUARE_H 0024 0025 #include "common.h" 0026 0027 /** @file file declaring the Square class */ 0028 0029 /** namespace for game engine */ 0030 namespace bovo 0031 { 0032 0033 /** 0034 * A class representing a square in a playing board 0035 * 0036 * This class represents a Square in a playing board. It knows 0037 * if it is empty or if it is marked by a player. 0038 * You can set it to a player, if it is empty, otherwise it will 0039 * throw an exception @c busy. 0040 * 0041 * @code 0042 * Square square; 0043 * if (square.empty()) { // <i>this will be true</i> 0044 * square.setPlayer(X); 0045 * } 0046 * Player player = square.player(); // <i>X</i> 0047 * @endcode 0048 */ 0049 class Square 0050 { 0051 public: 0052 /** 0053 * @brief Empty constructor 0054 * @description Thie constructs an empty square, 0055 * occupied by no player at all. 0056 */ 0057 Square(); 0058 0059 /** 0060 * @brief Is this Square empty? 0061 * @description Tells whether this square is empty (@c true) 0062 * or occupied by a player (@c false) 0063 * @return @c true if square is empty, @c false otherwise 0064 */ 0065 bool empty() const; 0066 0067 /** 0068 * @brief player of this square 0069 * @description tells whether this square is occupied by 0070 * player 1, player 2 och no player at all (empty). 0071 * @return player id (X or O) or (No) if empty 0072 */ 0073 Player player() const; 0074 0075 /** 0076 * @brief sets player id of this square 0077 * @description sets the player id of this square to X or O 0078 */ 0079 void setPlayer(Player player); 0080 0081 private: 0082 /* player property of this Square */ 0083 Player m_player; 0084 }; 0085 0086 } /* namespace bovo */ 0087 0088 #endif // BOVO_SQUARE_H