1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
/*
This file is part of StroQ, Copyright (C) 2005 Luc Vo Van
StroQ is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
StroQ is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with StroQ; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Class : Square
Author : Luc Vo Van
Original Date : 18.05.2005
Description : The basic element of which a Puzzle is made up. It can
have three different states (white, black, border).
*/
#ifndef SQUARE_H
#define SQUARE_H
#include <qpoint.h>
class Square
{
public:
/**
* The states that a Square can be in
*/
enum States {
White, /**< A white square */
Black, /**< A black square */
Border /**< A border square */
};
/**
* Constructs a Square from a position and a state
*
* @param pos the position of the Square
* @param state the State of the Square
*/
Square(QPoint pos, States state);
/**
* Virtual destructor
*/
virtual ~Square();
/**
* Compares the equality for two Squares.
*
* @return True if they have the same position, false otherwise
*/
bool operator==(Square&);
/**
* Compares the difference of two squares
*
* @return True if the two squares have different positions, false otherwise
*/
bool operator!=(Square&);
public:
/**
* Returns the position of the Square in the puzzle
*
* @return the position of the Square in the puzzle
*/
QPoint getGridPos() { return m_pqpGridPos; }
/**
* Returns the state of the Square
*
* @return the State of the Square
*/
Square::States getState() { return m_sState; }
/**
* Sets the state of the Square
*
* @param state the State to which to set the Square to
*/
void setState(Square::States state);
/**
* Toggles the square (white to black, black to white, border to border)
* Doesn't change Squares that are in Border state
*/
void toggle();
protected:
States m_sState; /**< State the Square is in */
QPoint m_pqpGridPos; /**< Position of the Square in the puzzle */
};
#endif
|