jsp
This commit is contained in:
parent
955e65bf0b
commit
59be28bf96
71
Hexagon.cpp
71
Hexagon.cpp
|
@ -1,4 +1,4 @@
|
||||||
#include "Hexagon.h"
|
//#include "Hexagon.h"
|
||||||
|
|
||||||
Hexagon::Hexagon()
|
Hexagon::Hexagon()
|
||||||
: top_m(nullptr), top_right_m(nullptr), top_left_m(nullptr),
|
: top_m(nullptr), top_right_m(nullptr), top_left_m(nullptr),
|
||||||
|
@ -75,115 +75,92 @@ void Hexagon::setTop(Hexagon* top)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hexagon::setTopRight(Hexagon* top_right)
|
void Hexagon::setTopRight(Hexagon* top_right) {
|
||||||
{
|
if (Hexagon::getTopRight() == nullptr) {
|
||||||
if (Hexagon::getTopRight() == nullptr)
|
|
||||||
{
|
|
||||||
top_right_m = top_right;
|
top_right_m = top_right;
|
||||||
top_right->setBottomLeft(this);
|
top_right->setBottomLeft(this);
|
||||||
|
|
||||||
if (Hexagon::getBottomRight() != nullptr)
|
if (Hexagon::getBottomRight() != nullptr) {
|
||||||
{
|
|
||||||
Hexagon::getBottomRight()->setTop(top_right);
|
Hexagon::getBottomRight()->setTop(top_right);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Hexagon::getTop() != nullptr)
|
if (Hexagon::getTop() != nullptr) {
|
||||||
{
|
|
||||||
Hexagon::getTop()->setBottomRight(top_right);
|
Hexagon::getTop()->setBottomRight(top_right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hexagon::setTopLeft(Hexagon* top_left)
|
void Hexagon::setTopLeft(Hexagon* top_left) {
|
||||||
{
|
if (Hexagon::getTopLeft() == nullptr) {
|
||||||
if (Hexagon::getTopLeft() == nullptr)
|
|
||||||
{
|
|
||||||
top_left_m = top_left;
|
top_left_m = top_left;
|
||||||
top_left->setBottomRight(this);
|
top_left->setBottomRight(this);
|
||||||
|
|
||||||
if (Hexagon::getTop() != nullptr)
|
if (Hexagon::getTop() != nullptr) {
|
||||||
{
|
|
||||||
Hexagon::getTop()->setBottomLeft(top_left);
|
Hexagon::getTop()->setBottomLeft(top_left);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Hexagon::getBottomLeft() != nullptr)
|
if (Hexagon::getBottomLeft() != nullptr) {
|
||||||
{
|
|
||||||
Hexagon::getBottomLeft()->setTop(top_left);
|
Hexagon::getBottomLeft()->setTop(top_left);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hexagon::setBottomRight(Hexagon* bottom_right)
|
void Hexagon::setBottomRight(Hexagon* bottom_right) {
|
||||||
{
|
if (Hexagon::getBottomRight() == nullptr) {
|
||||||
if (Hexagon::getBottomRight() == nullptr)
|
|
||||||
{
|
|
||||||
bottom_right_m = bottom_right;
|
bottom_right_m = bottom_right;
|
||||||
bottom_right->setTopLeft(this);
|
bottom_right->setTopLeft(this);
|
||||||
|
|
||||||
if (Hexagon::getTopRight() != nullptr)
|
if (Hexagon::getTopRight() != nullptr) {
|
||||||
{
|
|
||||||
Hexagon::getTopRight()->setBottom(bottom_right);
|
Hexagon::getTopRight()->setBottom(bottom_right);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Hexagon::getBottom() != nullptr)
|
if (Hexagon::getBottom() != nullptr) {
|
||||||
{
|
|
||||||
Hexagon::getBottom()->setTopRight(bottom_right);
|
Hexagon::getBottom()->setTopRight(bottom_right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hexagon::setBottomLeft(Hexagon* bottom_left)
|
void Hexagon::setBottomLeft(Hexagon* bottom_left) {
|
||||||
{
|
if (Hexagon::getBottomLeft() == nullptr) {
|
||||||
if (Hexagon::getBottomLeft() == nullptr)
|
|
||||||
{
|
|
||||||
bottom_left_m = bottom_left;
|
bottom_left_m = bottom_left;
|
||||||
bottom_left->setTopRight(this);
|
bottom_left->setTopRight(this);
|
||||||
|
|
||||||
if (Hexagon::getTopLeft() != nullptr)
|
if (Hexagon::getTopLeft() != nullptr) {
|
||||||
{
|
|
||||||
Hexagon::getTopLeft()->setBottom(bottom_left);
|
Hexagon::getTopLeft()->setBottom(bottom_left);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Hexagon::getBottom() != nullptr)
|
if (Hexagon::getBottom() != nullptr) {
|
||||||
{
|
|
||||||
Hexagon::getBottom()->setTopLeft(bottom_left);
|
Hexagon::getBottom()->setTopLeft(bottom_left);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hexagon::setBottom(Hexagon* bottom)
|
void Hexagon::setBottom(Hexagon* bottom) {
|
||||||
{
|
if (Hexagon::getBottom() == nullptr) {
|
||||||
if (Hexagon::getBottom() == nullptr)
|
|
||||||
{
|
|
||||||
bottom_m = bottom;
|
bottom_m = bottom;
|
||||||
bottom->setTop(this);
|
bottom->setTop(this);
|
||||||
|
|
||||||
if (Hexagon::getBottomLeft() != nullptr)
|
if (Hexagon::getBottomLeft() != nullptr) {
|
||||||
{
|
|
||||||
Hexagon::getBottomLeft()->setBottomRight(bottom);
|
Hexagon::getBottomLeft()->setBottomRight(bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Hexagon::getBottomRight() != nullptr)
|
if (Hexagon::getBottomRight() != nullptr) {
|
||||||
{
|
|
||||||
Hexagon::getBottomRight()->setBottomLeft(bottom);
|
Hexagon::getBottomRight()->setBottomLeft(bottom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hexagon::setCity(City city)
|
void Hexagon::setCity(City city) {
|
||||||
{
|
|
||||||
city_m = city;
|
city_m = city;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hexagon::setRessource(Ressource ressource)
|
void Hexagon::setRessource(Ressource ressource) {
|
||||||
{
|
|
||||||
ressource_m = ressource;
|
ressource_m = ressource;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------- Others ---------------------\\
|
//--------------------- Others ---------------------\\
|
||||||
|
|
||||||
void Hexagon::printHexagon() const
|
void Hexagon::printHexagon() const {
|
||||||
{
|
|
||||||
if(ressource_m.getValue() != 0)
|
if(ressource_m.getValue() != 0)
|
||||||
{
|
{
|
||||||
std::cout << "Ressource : ";
|
std::cout << "Ressource : ";
|
||||||
|
|
62
Hexagon.h
62
Hexagon.h
|
@ -1,60 +1,26 @@
|
||||||
#ifndef HEXAGON_H
|
#ifndef HEXAGON_H
|
||||||
#define HEXAGON_H
|
#define HEXAGON_H
|
||||||
|
|
||||||
#include<iostream>
|
|
||||||
|
|
||||||
#include "City.h"
|
|
||||||
#include "Ressource.h"
|
|
||||||
#include "Decoration.h"
|
|
||||||
|
|
||||||
class Hexagon {
|
class Hexagon {
|
||||||
private:
|
|
||||||
Hexagon* top_m;
|
|
||||||
Hexagon* top_right_m;
|
|
||||||
Hexagon* top_left_m;
|
|
||||||
Hexagon* bottom_right_m;
|
|
||||||
Hexagon* bottom_left_m;
|
|
||||||
Hexagon* bottom_m;
|
|
||||||
City city_m;
|
|
||||||
Ressource ressource_m;
|
|
||||||
Decoration decoration_m;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructors
|
|
||||||
Hexagon();
|
|
||||||
Hexagon(const City& city);
|
|
||||||
Hexagon(const Ressource& ressource);
|
|
||||||
Hexagon(const Decoration& decoration);
|
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
Hexagon* getTop() const;
|
virtual Hexagon* getTop() const;
|
||||||
Hexagon* getTopRight() const;
|
virtual Hexagon* getTopRight() const;
|
||||||
Hexagon* getTopLeft() const;
|
virtual Hexagon* getTopLeft() const;
|
||||||
Hexagon* getBottomRight() const;
|
virtual Hexagon* getBottomRight() const;
|
||||||
Hexagon* getBottomLeft() const;
|
virtual Hexagon* getBottomLeft() const;
|
||||||
Hexagon* getBottom() const;
|
virtual Hexagon* getBottom() const;
|
||||||
City getCity() const;
|
|
||||||
Ressource getRessource() const;
|
|
||||||
|
|
||||||
// Setters
|
|
||||||
void setTop(Hexagon* top);
|
|
||||||
void setTopRight(Hexagon* top_right);
|
|
||||||
void setTopLeft(Hexagon* top_left);
|
|
||||||
void setBottomRight(Hexagon* bottom_right);
|
|
||||||
void setBottomLeft(Hexagon* bottom_left);
|
|
||||||
void setBottom(Hexagon* bottom);
|
|
||||||
void setCity(City city);
|
|
||||||
void setRessource(Ressource ressource);
|
|
||||||
|
|
||||||
// Others
|
// Others
|
||||||
void printHexagon() const;
|
virtual void printHexagon() const;
|
||||||
void printTopLeft() const;
|
virtual void printTopLeft() const;
|
||||||
void printTop() const;
|
virtual void printTop() const;
|
||||||
void printTopRight() const;
|
virtual void printTopRight() const;
|
||||||
void printBottomRight() const;
|
virtual void printBottomRight() const;
|
||||||
void printBottom() const;
|
virtual void printBottom() const;
|
||||||
void printBottomLeft() const;
|
virtual void printBottomLeft() const;
|
||||||
void printAll() const;
|
virtual void printAll() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HEXAGON_H
|
#endif // HEXAGON_H
|
||||||
|
|
41
main.cpp
41
main.cpp
|
@ -2,9 +2,9 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Ressource.h"
|
#include "Ressource.h"
|
||||||
#include "City.h"
|
//#include "City.h"
|
||||||
#include "Decoration.h"
|
//#include "Decoration.h"
|
||||||
#include "Hexagon.h"
|
//#include "Hexagon.h"
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
// Init all resources
|
// Init all resources
|
||||||
|
@ -20,44 +20,13 @@ int main(int argc, char* argv[]) {
|
||||||
irons.emplace_back("Iron", i);
|
irons.emplace_back("Iron", i);
|
||||||
wheats.emplace_back("Wheat", i);
|
wheats.emplace_back("Wheat", i);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
City khamuls_tower_c("Khamûl's Tower");
|
City khamuls_tower_c("Khamûl's Tower");
|
||||||
City bazylan_c("Bazylan");
|
City bazylan_c("Bazylan");
|
||||||
City mordor_c("Mordor");
|
City mordor_c("Mordor");
|
||||||
|
|
||||||
Decoration angmar_banner("Angmar's Banner");
|
Decoration angmar_banner("Angmar's Banner");
|
||||||
|
*/
|
||||||
Hexagon hexagon_0_1(wheats[1]);
|
|
||||||
Hexagon hexagon_0_3(irons[2]);
|
|
||||||
|
|
||||||
Hexagon hexagon_1_0(bazylan_c);
|
|
||||||
Hexagon hexagon_1_2(khamuls_tower_c);
|
|
||||||
Hexagon hexagon_1_4(wheats[0]);
|
|
||||||
|
|
||||||
Hexagon hexagon_2_1(angmar_banner);
|
|
||||||
Hexagon hexagon_2_3(stones[0]);
|
|
||||||
Hexagon hexagon_2_5(mordor_c);
|
|
||||||
|
|
||||||
hexagon_1_0.setBottomRight(&hexagon_2_1);
|
|
||||||
hexagon_1_0.setBottomLeft(&hexagon_0_1);
|
|
||||||
|
|
||||||
hexagon_1_2.setTop(&hexagon_1_0);
|
|
||||||
hexagon_1_2.setBottomRight(&hexagon_2_3);
|
|
||||||
hexagon_1_2.setBottomLeft(&hexagon_0_3);
|
|
||||||
|
|
||||||
hexagon_1_4.setTop(&hexagon_1_2);
|
|
||||||
hexagon_1_4.setBottomRight(&hexagon_2_5);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
hexagon_0_1.printAll();
|
|
||||||
hexagon_0_3.printAll();
|
|
||||||
hexagon_1_0.printAll();
|
|
||||||
hexagon_1_2.printAll();
|
|
||||||
hexagon_1_4.printAll();
|
|
||||||
hexagon_2_1.printAll();
|
|
||||||
hexagon_2_3.printAll();
|
|
||||||
hexagon_2_5.printAll();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue