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()
|
||||
: 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)
|
||||
{
|
||||
if (Hexagon::getTopRight() == nullptr)
|
||||
{
|
||||
void Hexagon::setTopRight(Hexagon* top_right) {
|
||||
if (Hexagon::getTopRight() == nullptr) {
|
||||
top_right_m = top_right;
|
||||
top_right->setBottomLeft(this);
|
||||
|
||||
if (Hexagon::getBottomRight() != nullptr)
|
||||
{
|
||||
if (Hexagon::getBottomRight() != nullptr) {
|
||||
Hexagon::getBottomRight()->setTop(top_right);
|
||||
}
|
||||
|
||||
if (Hexagon::getTop() != nullptr)
|
||||
{
|
||||
if (Hexagon::getTop() != nullptr) {
|
||||
Hexagon::getTop()->setBottomRight(top_right);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Hexagon::setTopLeft(Hexagon* top_left)
|
||||
{
|
||||
if (Hexagon::getTopLeft() == nullptr)
|
||||
{
|
||||
void Hexagon::setTopLeft(Hexagon* top_left) {
|
||||
if (Hexagon::getTopLeft() == nullptr) {
|
||||
top_left_m = top_left;
|
||||
top_left->setBottomRight(this);
|
||||
|
||||
if (Hexagon::getTop() != nullptr)
|
||||
{
|
||||
if (Hexagon::getTop() != nullptr) {
|
||||
Hexagon::getTop()->setBottomLeft(top_left);
|
||||
}
|
||||
|
||||
if (Hexagon::getBottomLeft() != nullptr)
|
||||
{
|
||||
if (Hexagon::getBottomLeft() != nullptr) {
|
||||
Hexagon::getBottomLeft()->setTop(top_left);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Hexagon::setBottomRight(Hexagon* bottom_right)
|
||||
{
|
||||
if (Hexagon::getBottomRight() == nullptr)
|
||||
{
|
||||
void Hexagon::setBottomRight(Hexagon* bottom_right) {
|
||||
if (Hexagon::getBottomRight() == nullptr) {
|
||||
bottom_right_m = bottom_right;
|
||||
bottom_right->setTopLeft(this);
|
||||
|
||||
if (Hexagon::getTopRight() != nullptr)
|
||||
{
|
||||
if (Hexagon::getTopRight() != nullptr) {
|
||||
Hexagon::getTopRight()->setBottom(bottom_right);
|
||||
}
|
||||
|
||||
if (Hexagon::getBottom() != nullptr)
|
||||
{
|
||||
if (Hexagon::getBottom() != nullptr) {
|
||||
Hexagon::getBottom()->setTopRight(bottom_right);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Hexagon::setBottomLeft(Hexagon* bottom_left)
|
||||
{
|
||||
if (Hexagon::getBottomLeft() == nullptr)
|
||||
{
|
||||
void Hexagon::setBottomLeft(Hexagon* bottom_left) {
|
||||
if (Hexagon::getBottomLeft() == nullptr) {
|
||||
bottom_left_m = bottom_left;
|
||||
bottom_left->setTopRight(this);
|
||||
|
||||
if (Hexagon::getTopLeft() != nullptr)
|
||||
{
|
||||
if (Hexagon::getTopLeft() != nullptr) {
|
||||
Hexagon::getTopLeft()->setBottom(bottom_left);
|
||||
}
|
||||
|
||||
if (Hexagon::getBottom() != nullptr)
|
||||
{
|
||||
if (Hexagon::getBottom() != nullptr) {
|
||||
Hexagon::getBottom()->setTopLeft(bottom_left);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Hexagon::setBottom(Hexagon* bottom)
|
||||
{
|
||||
if (Hexagon::getBottom() == nullptr)
|
||||
{
|
||||
void Hexagon::setBottom(Hexagon* bottom) {
|
||||
if (Hexagon::getBottom() == nullptr) {
|
||||
bottom_m = bottom;
|
||||
bottom->setTop(this);
|
||||
|
||||
if (Hexagon::getBottomLeft() != nullptr)
|
||||
{
|
||||
if (Hexagon::getBottomLeft() != nullptr) {
|
||||
Hexagon::getBottomLeft()->setBottomRight(bottom);
|
||||
}
|
||||
|
||||
if (Hexagon::getBottomRight() != nullptr)
|
||||
{
|
||||
if (Hexagon::getBottomRight() != nullptr) {
|
||||
Hexagon::getBottomRight()->setBottomLeft(bottom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Hexagon::setCity(City city)
|
||||
{
|
||||
void Hexagon::setCity(City city) {
|
||||
city_m = city;
|
||||
}
|
||||
|
||||
void Hexagon::setRessource(Ressource ressource)
|
||||
{
|
||||
void Hexagon::setRessource(Ressource ressource) {
|
||||
ressource_m = ressource;
|
||||
}
|
||||
|
||||
//--------------------- Others ---------------------\\
|
||||
|
||||
void Hexagon::printHexagon() const
|
||||
{
|
||||
void Hexagon::printHexagon() const {
|
||||
if(ressource_m.getValue() != 0)
|
||||
{
|
||||
std::cout << "Ressource : ";
|
||||
|
|
62
Hexagon.h
62
Hexagon.h
|
@ -1,60 +1,26 @@
|
|||
#ifndef HEXAGON_H
|
||||
#define HEXAGON_H
|
||||
|
||||
#include<iostream>
|
||||
|
||||
#include "City.h"
|
||||
#include "Ressource.h"
|
||||
#include "Decoration.h"
|
||||
|
||||
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:
|
||||
// Constructors
|
||||
Hexagon();
|
||||
Hexagon(const City& city);
|
||||
Hexagon(const Ressource& ressource);
|
||||
Hexagon(const Decoration& decoration);
|
||||
|
||||
// Getters
|
||||
Hexagon* getTop() const;
|
||||
Hexagon* getTopRight() const;
|
||||
Hexagon* getTopLeft() const;
|
||||
Hexagon* getBottomRight() const;
|
||||
Hexagon* getBottomLeft() const;
|
||||
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);
|
||||
virtual Hexagon* getTop() const;
|
||||
virtual Hexagon* getTopRight() const;
|
||||
virtual Hexagon* getTopLeft() const;
|
||||
virtual Hexagon* getBottomRight() const;
|
||||
virtual Hexagon* getBottomLeft() const;
|
||||
virtual Hexagon* getBottom() const;
|
||||
|
||||
// Others
|
||||
void printHexagon() const;
|
||||
void printTopLeft() const;
|
||||
void printTop() const;
|
||||
void printTopRight() const;
|
||||
void printBottomRight() const;
|
||||
void printBottom() const;
|
||||
void printBottomLeft() const;
|
||||
void printAll() const;
|
||||
virtual void printHexagon() const;
|
||||
virtual void printTopLeft() const;
|
||||
virtual void printTop() const;
|
||||
virtual void printTopRight() const;
|
||||
virtual void printBottomRight() const;
|
||||
virtual void printBottom() const;
|
||||
virtual void printBottomLeft() const;
|
||||
virtual void printAll() const;
|
||||
};
|
||||
|
||||
#endif // HEXAGON_H
|
||||
|
|
41
main.cpp
41
main.cpp
|
@ -2,9 +2,9 @@
|
|||
#include <vector>
|
||||
|
||||
#include "Ressource.h"
|
||||
#include "City.h"
|
||||
#include "Decoration.h"
|
||||
#include "Hexagon.h"
|
||||
//#include "City.h"
|
||||
//#include "Decoration.h"
|
||||
//#include "Hexagon.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
// Init all resources
|
||||
|
@ -20,44 +20,13 @@ int main(int argc, char* argv[]) {
|
|||
irons.emplace_back("Iron", i);
|
||||
wheats.emplace_back("Wheat", i);
|
||||
}
|
||||
|
||||
/*
|
||||
City khamuls_tower_c("Khamûl's Tower");
|
||||
City bazylan_c("Bazylan");
|
||||
City mordor_c("Mordor");
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue