mis en place la PR de simon sur les couleurs
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Cell.h"
|
||||
#include "Position.h"
|
||||
|
||||
#include <Vector>
|
||||
#include <Set>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
@@ -12,19 +12,19 @@
|
||||
*/
|
||||
class Polyomino {
|
||||
private:
|
||||
std::set<Cell> cells; // the squares composing the polyomino, (0,0) is downleft
|
||||
int length; // the size of the smallest square in which the polyomino can fit on any rotation
|
||||
std::set<Position> positions; // the squares composing the polyomino, (0,0) is downleft
|
||||
int length; // the size of the smallest square box in which the polyomino can fit on any rotation
|
||||
|
||||
public:
|
||||
/**
|
||||
* Creates a polyomino with the specified cells and normalizes it, wheter it is actually a polyonimo is not checked
|
||||
* Creates a polyomino with the specified positions and normalizes it, wheter it is actually a polyonimo is not checked
|
||||
*/
|
||||
Polyomino(const std::set<Cell>& cells);
|
||||
Polyomino(const std::set<Position>& positions);
|
||||
|
||||
/**
|
||||
* Creates a polyomino with the specified cells and length, wheter it is actually a polyonimo of this length is not checked
|
||||
* Creates a polyomino with the specified positions and length, wheter it is actually a polyonimo of this length is not checked
|
||||
*/
|
||||
Polyomino(const std::set<Cell>& cells, int length);
|
||||
Polyomino(const std::set<Position>& positions, int length);
|
||||
|
||||
/**
|
||||
* Translates the polyomino to the lowest unsigned values (lower row on y = 0, and left-most column on x = 0)
|
||||
@@ -32,17 +32,17 @@ class Polyomino {
|
||||
void normalize();
|
||||
|
||||
/**
|
||||
* Rotates the polyomino 90° clockwise, the center of rotation being the middle of the square going from (0,0) to (length-1, length-1)
|
||||
* Rotates the polyomino 90° clockwise, the center of rotation being the middle of the box going from (0,0) to (length-1, length-1)
|
||||
*/
|
||||
void rotateCW();
|
||||
|
||||
/**
|
||||
* Rotates the polyomino 180°, the center of rotation being the middle of the square going from (0,0) to (length-1, length-1)
|
||||
* Rotates the polyomino 180°, the center of rotation being the middle of the box going from (0,0) to (length-1, length-1)
|
||||
*/
|
||||
void rotate180();
|
||||
|
||||
/**
|
||||
* Rotates the polyomino 90° counter-clockwise, the center of rotation being the middle of the square going from (0,0) to (length-1, length-1)
|
||||
* Rotates the polyomino 90° counter-clockwise, the center of rotation being the middle of the box going from (0,0) to (length-1, length-1)
|
||||
*/
|
||||
void rotateCCW();
|
||||
|
||||
@@ -59,12 +59,14 @@ class Polyomino {
|
||||
|
||||
public:
|
||||
/**
|
||||
* Returns wheter the polyomino is convex, that is if every line and column has at most one continuous line of cells
|
||||
* Check if the polyomino is convex, that is if every line and column has at most one continuous line of positions
|
||||
* @return If the polyomino is convex
|
||||
*/
|
||||
bool isConvex() const;
|
||||
|
||||
/**
|
||||
* Returns wheter the polyomino has at least one hole
|
||||
* Check if the polyomino has at least one hole
|
||||
* @return If the polyomino has at least one hole
|
||||
*/
|
||||
bool hasHole() const;
|
||||
|
||||
@@ -72,37 +74,40 @@ class Polyomino {
|
||||
/**
|
||||
* Auxiliary method of hasHole()
|
||||
*/
|
||||
void tryToInsertCell(std::set<Cell>& emptyCells, const Cell& candidate) const;
|
||||
void tryToInsertPosition(std::set<Position>& emptypositions, const Position& candidate) const;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Returns a copy of the cells of the polyomino
|
||||
* @return A copy of the positions of the polyomino
|
||||
*/
|
||||
std::set<Cell> getCells() const;
|
||||
std::set<Position> getPositions() const;
|
||||
|
||||
/**
|
||||
* Returns the length of the polyomino
|
||||
* @return The length of the polyomino
|
||||
*/
|
||||
int getLength() const;
|
||||
|
||||
/**
|
||||
* Returns the number of squares in the polyomino
|
||||
* @return The number of squares in the polyomino
|
||||
*/
|
||||
int getPolyominoOrder() const;
|
||||
int getPolyominoSize() const;
|
||||
|
||||
/**
|
||||
* Strict inferiority operator, a polyomino is inferior than another if it has a smaller length, or if they are the same length,
|
||||
* while checking from left to right and top to bottom, is the first which has a cell while the other doesn't
|
||||
* while checking from left to right and top to bottom, is the first which has a square while the other don't
|
||||
* @return If the polyomino is inferior than another
|
||||
*/
|
||||
bool operator<(const Polyomino& other) const;
|
||||
|
||||
/**
|
||||
* Equality operator, two polyominos are equal if they overlap, that means two polyominos of the same shape but different positions will not be equal
|
||||
* Equality operator, two polyominos are equal if their positions are the same, that means two polyominos of the same shape at different places will not be equal
|
||||
* @return If the polyomino is equal to another
|
||||
*/
|
||||
bool operator ==(const Polyomino& other) const;
|
||||
|
||||
/**
|
||||
* Stream output operator, adds a 2D grid representing the polyomino
|
||||
* @return A reference to the output stream
|
||||
*/
|
||||
friend std::ostream& operator<<(std::ostream& os, const Polyomino& polyomino);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user