split classes into multiples files
This commit is contained in:
parent
ef5383913f
commit
51ccb97cf0
11 changed files with 56 additions and 27 deletions
|
@ -21,7 +21,7 @@ public:
|
||||||
Dames(Joueur &joueur1, Joueur &joueur2); // constructor
|
Dames(Joueur &joueur1, Joueur &joueur2); // constructor
|
||||||
virtual ~Dames(); // destructor
|
virtual ~Dames(); // destructor
|
||||||
|
|
||||||
Dames(const Dames &d); // copy constructor
|
Dames(const Dames &); // copy constructor
|
||||||
const Dames &operator=(const Dames &); // copy assignement
|
const Dames &operator=(const Dames &); // copy assignement
|
||||||
|
|
||||||
// Fonction d'initialisation du jeu
|
// Fonction d'initialisation du jeu
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#define JOUEUR
|
#define JOUEUR
|
||||||
|
|
||||||
#include "../includes/Piece.hpp"
|
#include "../includes/Piece.hpp"
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class Joueur {
|
class Joueur {
|
||||||
|
|
|
@ -17,18 +17,4 @@ public:
|
||||||
const Piece &operator=(const Piece &); // copy assignement
|
const Piece &operator=(const Piece &); // copy assignement
|
||||||
};
|
};
|
||||||
|
|
||||||
class PieceDames : public Piece {
|
|
||||||
public:
|
|
||||||
PieceDames(std::string categorie);
|
|
||||||
virtual ~PieceDames();
|
|
||||||
};
|
|
||||||
|
|
||||||
class PieceButin : public Piece {
|
|
||||||
int points;
|
|
||||||
|
|
||||||
public:
|
|
||||||
PieceButin(std::string categorie);
|
|
||||||
virtual ~PieceButin();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
14
includes/PieceButin.hpp
Normal file
14
includes/PieceButin.hpp
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#ifndef PIECEEE
|
||||||
|
#define PIECEEE
|
||||||
|
|
||||||
|
#include "Piece.hpp"
|
||||||
|
|
||||||
|
class PieceButin : public Piece {
|
||||||
|
int points;
|
||||||
|
|
||||||
|
public:
|
||||||
|
PieceButin(std::string categorie);
|
||||||
|
virtual ~PieceButin();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
12
includes/PieceDames.hpp
Normal file
12
includes/PieceDames.hpp
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef PIECEE
|
||||||
|
#define PIECEE
|
||||||
|
|
||||||
|
#include "Piece.hpp"
|
||||||
|
|
||||||
|
class PieceDames : public Piece {
|
||||||
|
public:
|
||||||
|
PieceDames(std::string categorie);
|
||||||
|
virtual ~PieceDames();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -2,8 +2,6 @@
|
||||||
#define PLATEAU
|
#define PLATEAU
|
||||||
|
|
||||||
#include "../includes/Joueur.hpp"
|
#include "../includes/Joueur.hpp"
|
||||||
#include "../includes/Piece.hpp"
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
class Plateau {
|
class Plateau {
|
||||||
friend std::ostream &operator<<(std::ostream &, const Plateau &);
|
friend std::ostream &operator<<(std::ostream &, const Plateau &);
|
||||||
|
@ -15,7 +13,6 @@ class Plateau {
|
||||||
Piece ***plateau;
|
Piece ***plateau;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Plateau();
|
|
||||||
Plateau(int taille); // constructor
|
Plateau(int taille); // constructor
|
||||||
virtual ~Plateau(); // destructor
|
virtual ~Plateau(); // destructor
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
#include "../includes/Dames.hpp"
|
#include "../includes/Dames.hpp"
|
||||||
|
|
||||||
Dames::Dames(Joueur &j1, Joueur &j2)
|
Dames::Dames(Joueur &j1, Joueur &j2)
|
||||||
: joueur1{j1}, joueur2{j2}, joueurCourant{j1} {
|
: plateau(Plateau(10)), joueur1{j1}, joueur2{j2}, joueurCourant{j1} {
|
||||||
Plateau p(10);
|
|
||||||
this->plateau = p;
|
|
||||||
plateau.initialiserPlateau(j1, j2);
|
plateau.initialiserPlateau(j1, j2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dames::~Dames() {}
|
Dames::~Dames() {}
|
||||||
|
|
||||||
Dames::Dames(const Dames &d)
|
Dames::Dames(const Dames &src)
|
||||||
: joueur1{d.joueur1}, joueur2{d.joueur2}, joueurCourant{d.joueurCourant} {}
|
: plateau(Plateau(10)), joueur1{src.joueur1}, joueur2{src.joueur2},
|
||||||
|
joueurCourant{src.joueurCourant} {
|
||||||
|
plateau.initialiserPlateau(joueur1, joueur2);
|
||||||
|
}
|
||||||
|
|
||||||
const Dames &Dames::operator=(const Dames &src) {
|
const Dames &Dames::operator=(const Dames &src) {
|
||||||
if (this == &src) {
|
if (this == &src) {
|
||||||
|
|
7
src/PieceButin.cpp
Normal file
7
src/PieceButin.cpp
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#include "../includes/PieceButin.hpp"
|
||||||
|
|
||||||
|
PieceButin::PieceButin(const std::string cat) : Piece(cat) {
|
||||||
|
std::cout << "pièce - " << cat << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
PieceButin::~PieceButin() {}
|
7
src/PieceDames.cpp
Normal file
7
src/PieceDames.cpp
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#include "../includes/PieceDames.hpp"
|
||||||
|
|
||||||
|
PieceDames::PieceDames(const std::string cat) : Piece(cat) {
|
||||||
|
std::cout << "pièce - " << cat << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
PieceDames::~PieceDames() {}
|
|
@ -1,6 +1,5 @@
|
||||||
#include "../includes/Plateau.hpp"
|
#include "../includes/Plateau.hpp"
|
||||||
|
#include "../includes/PieceDames.hpp"
|
||||||
Plateau::Plateau() {}
|
|
||||||
|
|
||||||
Plateau::Plateau(int t) {
|
Plateau::Plateau(int t) {
|
||||||
// Création du plateau vide
|
// Création du plateau vide
|
||||||
|
@ -39,6 +38,7 @@ void Plateau::initialiserPlateau(Joueur &j1, Joueur &j2) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 6; i < 10; i++) {
|
for (int i = 6; i < 10; i++) {
|
||||||
for (int j = 0; j < 10; j++) {
|
for (int j = 0; j < 10; j++) {
|
||||||
if ((i % 2 == 0 && j % 2 == 1) || (i % 2 == 1 && j % 2 == 0)) {
|
if ((i % 2 == 0 && j % 2 == 1) || (i % 2 == 1 && j % 2 == 0)) {
|
||||||
|
|
|
@ -1,2 +1,8 @@
|
||||||
|
#include "../includes/Ecran.hpp"
|
||||||
|
|
||||||
int main() { return 0; }
|
int main() {
|
||||||
|
Ecran e;
|
||||||
|
e.afficher();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Reference in a new issue