K.O : Définitions multiples

master
Alexandre 2020-04-25 18:09:05 +02:00
commit e68f62b756
13 changed files with 399 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
bin/
LesTortuesB1C1.cbp
LesTortuesB1C1.cscope_file_list
LesTortuesB1C1.depend
LesTortuesB1C1.layout
obj/

27
include/Carte.h Normal file
View File

@ -0,0 +1,27 @@
#ifndef CARTE_H
#define CARTE_H 1
#include <string>
using namespace std;
class Carte
{
public:
Carte();
Carte(int couleur, int type);
virtual ~Carte();
void afficher();
string representation_type_carte(int type_carte);
int getCouleur();
void setCouleur(int couleur);
void setType(int type);
int getType();
int deplacement_type_carte(int type_carte);
protected:
private:
int couleur;
int type;
};
#endif // CARTE_H

25
include/Joueur.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef JOUEUR_H
#define JOUEUR_H
#include <iostream>
using namespace std;
class Joueur
{
public:
Joueur();
Joueur(std::string nom, int age);
virtual ~Joueur();
int getAge();
void setNom(std::string nom);
std::string getNom();
affichage_joueur();
protected:
private:
std::string nom;
int age;
class Tortue* tortueJoueur;
class Carte* mainJoueur[5];
int nb_feuilles_de_salade;
};
#endif // JOUEUR_H

18
include/PiocheDeCartes.h Normal file
View File

@ -0,0 +1,18 @@
#ifndef PIOCHEDECARTES_H
#define PIOCHEDECARTES_H 1
#include "Carte.h"
#include <vector>
class PiocheDeCartes
{
public:
PiocheDeCartes();
virtual ~PiocheDeCartes();
Carte* piocher();
protected:
vector<Carte*> tas;
int nb_cartes_restantes;
private:
};
#endif // PIOCHEDECARTES_H

16
include/PiocheDeTortues.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef PIOCHEDETORTUES_H
#define PIOCHEDETORTUES_H
class PiocheDeTortues
{
public:
PiocheDeTortues();
virtual ~PiocheDeTortues();
protected:
private:
};
#endif // PIOCHEDETORTUES_H

23
include/Tortue.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef TORTUE_H
#define TORTUE_H
class Tortue
{
public:
Tortue(int couleur_t);
virtual ~Tortue();
int Getcouleur();
void Setcouleur(int val);
int Getposition();
void Setposition(int val);
void affichageTortue();
protected:
private:
int couleur;
int position;
};
#endif // TORTUE_H

53
include/constantes.h Normal file
View File

@ -0,0 +1,53 @@
#ifndef CONSTANTES_H
#define CONSTANTES_H
#include <string>
using namespace std;
/*
* REGLES DU JEU
*/
#define NB_POSITIONS 10
#define NB_MAX_JOUEURS 5
#define NB_CARTES_MAIN 5
#define NB_MAX_FEUILLES_SALADE 3
#define NB_TORTUES 5 // inchangeable car égal au nombre de couleurs
/*
* COULEUR : type int
*/
#define C_MULTI 0
#define C_ROUGE 1
#define C_BLEU 2
#define C_VIOLET 3
#define C_JAUNE 4
#define C_VERT 5
int TAB_COULEUR[5] = {C_ROUGE, C_BLEU, C_VIOLET, C_JAUNE, C_VERT};
#define TAILLE_TAB_COULEUR 5
/*
* TYPES DE CARTES : type int
*/
#define T_PLUS1_COULEUR 1
#define T_PLUS2_COULEUR 2
#define T_MOINS1_COULEUR -1
#define T_PLUS1_MULTI 4
#define T_MOINS1_MULTI -4
#define T_PLUS1_DERNIERE 7
#define T_PLUS2_DERNIERE 8
string AFFICHAGE_PLUS1 = "+";
string AFFICHAGE_PLUS2 = "+ +";
string AFFICHAGE_MOINS1 = "-";
string AFFICHAGE_PLUS1_DERNIERE = ">";
string AFFICHAGE_PLUS2_DERNIERE = "> >";
/*
* WINDOWS
*/
#endif // CONSTANTES_H

23
main.cpp Normal file
View File

@ -0,0 +1,23 @@
#include <iostream>
#include <vector>
#include "Carte.h"
#include "Tortue.h"
#include "Joueur.h"
using namespace std;
int main()
{
Carte* uneCarte;
uneCarte = new Carte();
Carte* uneAutre = new Carte();
uneCarte->setCouleur(5);
uneCarte->afficher();
uneAutre->setType(2);
uneAutre->afficher();
Joueur* unJoueur;
unJoueur = new Joueur();
Tortue* uneTortue;
uneTortue = new Tortue(3);
uneTortue->affichageTortue();
return 0;
}

79
src/Carte.cpp Normal file
View File

@ -0,0 +1,79 @@
#include <iostream>
#include "Carte.h"
#include "constantes.h"
using namespace std;
Carte::Carte()
{
cout << "Création d'une nouvelle carte !" << endl;
this->couleur = 0;
this->type = 0;
}
Carte::Carte(int couleur, int type)
{
this->setCouleur(couleur);
this->setType(type);
}
Carte::~Carte()
{
//dtor
}
string Carte::representation_type_carte(int type_carte)
{
switch (type_carte)
{
case T_PLUS1_COULEUR:
case T_PLUS1_MULTI:
return AFFICHAGE_PLUS1;
case T_PLUS2_COULEUR:
return AFFICHAGE_PLUS2;
case T_MOINS1_COULEUR:
case T_MOINS1_MULTI:
return AFFICHAGE_MOINS1;
case T_PLUS1_DERNIERE:
return AFFICHAGE_PLUS1_DERNIERE;
case T_PLUS2_DERNIERE:
return AFFICHAGE_PLUS2_DERNIERE;
}
return "";
}
void Carte::afficher(){
cout<<"Représentation de la carte :"<<this->representation_type_carte(this->type)<<endl;
}
void Carte::setType(int type) {
this->type=type;
}
int Carte::getType(){
return this->type;
}
void Carte::setCouleur(int couleur){
if(couleur<5){
this->couleur=couleur;
}
else{
this->couleur=0;
}
}
int Carte::getCouleur(){
cout<<"acces a la variablle couleur de l'objet "<<this<<endl;
return this->couleur;
}
int deplacement_type_carte (int type_carte)
{
return type_carte % 3;
}

35
src/Joueur.cpp Normal file
View File

@ -0,0 +1,35 @@
#include "Joueur.h"
Joueur::Joueur()
{
std::cout << "Quel age as-tu ?" << std::endl;
std::cin >> this->age;
std::cout << this->age << std::endl;
std::cout << "Quel est ton nom ?"<<std::endl;
std::cin >> this->nom;
std::cout << "Ton nom est : " << this->nom << ", et ton age est"<< this->age << std::endl;
}
Joueur::Joueur(std::string nom, int age)
{
this->nom = nom;
this->age = age;
this->nb_feuilles_de_salade = 0;
}
int Joueur::getAge()
{
return this->age;
}
std::string Joueur::getNom()
{
return this->nom;
}
Joueur::~Joueur()
{
//dtor
}

40
src/PiocheDeCartes.cpp Normal file
View File

@ -0,0 +1,40 @@
#include "PiocheDeCartes.h"
#include <iostream>
#include "constantes.h"
using namespace std;
PiocheDeCartes::PiocheDeCartes()
{
int nbCartesCreees = 0;
cout << "Creation de la pioche !" << endl;
for (int index_couleur = 0; index_couleur < TAILLE_TAB_COULEUR; index_couleur++)
{
for (int nb_cartes = 0; nb_cartes < 5; nb_cartes++)
{
Carte* uneCarte;
uneCarte = new Carte(TAB_COULEUR[index_couleur], T_PLUS1_COULEUR);
this->tas.push_back(uneCarte);
nbCartesCreees++;
}
for (int nb_cartes = 0; nb_cartes < 2; nb_cartes++)
{
Carte* uneCarte;
uneCarte = new Carte(TAB_COULEUR[index_couleur], T_MOINS1_COULEUR);
this->tas.push_back(uneCarte);
nbCartesCreees++;
}
Carte* uneCarte;
this->tas.push_back(uneCarte);
for (int nb_cartes = 0; nb_cartes < 5)
}
//ctor
}
Carte* PiocheDeCartes::piocher()
{
}
PiocheDeCartes::~PiocheDeCartes()
{
//dtor
}

11
src/PiocheDeTortues.cpp Normal file
View File

@ -0,0 +1,11 @@
#include "PiocheDeTortues.h"
PiocheDeTortues::PiocheDeTortues()
{
//ctor
}
PiocheDeTortues::~PiocheDeTortues()
{
//dtor
}

43
src/Tortue.cpp Normal file
View File

@ -0,0 +1,43 @@
#include <iostream>
#include <cstdlib>
#include <string>
#include "Tortue.h"
using namespace std;
Tortue::Tortue(int couleur_t)
{
if (couleur_t < 0 || couleur_t > 5)
{
cerr << "Erreur dans la création de la tortue :" <<endl;
}
cout<< "Création d'une tortue !"<<endl;
this->couleur = couleur_t;
this->position = 0;
//ctor
}
Tortue::~Tortue()
{
//dtor
}
int Tortue::Getcouleur()
{
return this->couleur;
}
void Tortue::Setcouleur(int val)
{
this->couleur = val;
}
int Tortue::Getposition()
{
return this->position;
}
void Tortue::Setposition(int val)
{
this->position = val;
}
void Tortue::affichageTortue()
{
std::cout << "Affichage de la couleur : "<<this->Getcouleur()<<std::endl;
std::cout << "Affichage de la position : "<<this->Getposition()<<std::endl;
}