Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #3

Merged
merged 26 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
main.cpp
main.cpp
7 changes: 5 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@
"ostream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"typeinfo": "cpp"
}
"typeinfo": "cpp",
"fstream": "cpp",
"sstream": "cpp"
},
"cmake.sourceDirectory": "a:/workspace/special-broccoli/app"
}
45 changes: 45 additions & 0 deletions Championnat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#ifndef CHAMPIONNAT_H
#define CHAMPIONNAT_H

#include "Joueur.h"
#include "Ticket.h"
#include "Partie.h"
#include "Tennis.h"

#include<string>
#include<vector>

class Championnat {

private:
string nom; // Declare the members
int annee;
int nbTours;
TennisChampionship* tennisChampionship; // Declare tennisChampionship as a member
vector<Joueur> joueursInscrits; // Add a vector to store the players

public:
std::vector<Joueur> joueursInscrits; // Enrolled players
std::vector<Partie> parties; // Played matches
std::vector<Ticket> tickets; // Tickets sold

// Constructor
Championnat::Championnat(const string& nom, int annee, int nbTours);

// Method to add players to the tournament
void inscrireJoueur(const Joueur& joueur);

// Method to get the list of enrolled players
const std::vector<Joueur>& getJoueursInscrits() const;

// Getters and Setters
string getNom() const { return nom; }
int getAnnee() const { return annee; }
int getNbTours() const { return nbTours; }
TennisChampionship* getTennisChampionship() const { return tennisChampionship; } // Getter for tennisChampionship
void setNom(const string& nom) { this->nom = nom; }
void setAnnee(int annee) { this->annee = annee; }
void setNbTours(int nbTours) { this->nbTours = nbTours; }
};

#endif
14 changes: 14 additions & 0 deletions Championnat.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "Championnat.h"

Championnat::Championnat(const string& nom, int annee, int nbTours)
: nom(nom), annee(annee), nbTours(nbTours), tennisChampionship(new TennisChampionship()) {} // Initialize tennisChampionship in the initializer list

// Method to add players to the tournament
void Championnat::inscrireJoueur(const Joueur& joueur) {
joueursInscrits.push_back(joueur);
}

// Method to get the list of enrolled players
const std::vector<Joueur>& Championnat::getJoueursInscrits() const {
return joueursInscrits;
}
41 changes: 41 additions & 0 deletions Client.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef CLIENTS_H
#define CLIENTS_H

#include <string>
#include <vector>
#include <map>

#include "Ticket.h"

class Client
{
public:
Client(const std::string &nom, int age, const std::string &adresse, const std::string &telephone);

// Getters
std::string getNom() const;
int getAge() const;
std::string getAdresse() const;
std::string getTelephone() const;

// Setters
int setNom(const std::string &nom);
int setAge(int age);
int setAdresse(const std::string &adresse);
int setTelephone(const std::string &telephone);

// Add a ticket to the client's list
void addTicket(Ticket *ticket);

// Display client information
void afficher() const;

private:
std::string nom;
int age;
std::string adresse;
std::string telephone;
std::vector<Ticket *> tickets;
};

#endif
65 changes: 65 additions & 0 deletions Client.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

#include "Client.h"
#include <iostream>

Client::Client(const std::string &nom, int age, const std::string &adresse, const std::string &telephone)
: nom(nom), age(age), adresse(adresse), telephone(telephone) {}

// Getters
string Client::getNom() const { return nom; }
int Client::getAge() const { return age; }
string Client::getAdresse() const { return adresse; }
string Client::getTelephone() const { return telephone; }

// Setters
int Client::setNom(const string &nom)
{
this->nom = nom;
return 0; // Success
}

int Client::setAge(int age)
{
if (age > 0)
{
this->age = age;
return 0; // Success
}
else
{
return 1; // Error: Invalid age
}
}

int Client::setAdresse(const string &adresse)
{
this->adresse = adresse;
return 0; // Success
}

int Client::setTelephone(const string &telephone)
{
this->telephone = telephone;
return 0; // Success
}

// Add a ticket to the client's list
void Client::addTicket(Ticket *ticket)
{
tickets.push_back(ticket);
}

// Display client information
void Client::afficher() const
{
cout << "Nom: " << nom << endl;
cout << "Age: " << age << endl;
cout << "Adresse: " << adresse << endl;
cout << "Telephone: " << telephone << endl;
cout << "Tickets:" << endl;
for (const Ticket *ticket : tickets)
{
ticket->afficher();
}
cout << endl;
}
48 changes: 48 additions & 0 deletions DataManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#ifndef DATAMANAGER_H
#define DATAMANAGER_H

#include <iostream>
#include <fstream>
#include <vector>

#include "Reservation.h"
#include "Joueur.h"
#include "Partie.h"
#include "Score.h"
#include "Paiements.h"

class DataManager
{
public:
// Constructor
DataManager();

// Destructor
~DataManager();

// Methods for saving and loading data
void sauvegarderReservations(const std::string &filename, const std::vector<Reservation> &reservations) const;
void chargerReservations(const std::string &filename, std::vector<Reservation> &reservations);

void sauvegarderJoueurs(const std::string &filename, const std::vector<Joueur> &joueurs) const;
void chargerJoueurs(const std::string &filename, std::vector<Joueur> &joueurs);

void sauvegarderParties(const std::string &filename, const std::vector<Partie> &parties) const;
void chargerParties(const std::string &filename, std::vector<Partie> &parties);

void sauvegarderScores(const std::string &filename, const std::vector<Score> &scores) const;
void chargerScores(const std::string &filename, std::vector<Score> &scores);



private:
// Helper function to save data to a file
template <typename T>
void sauvegarderDonnees(const std::string &filename, const std::vector<T> &data) const;

// Helper function to load data from a file
template <typename T>
void chargerDonnees(const std::string &filename, std::vector<T> &data);
};

#endif // DATAMANAGER_H
107 changes: 107 additions & 0 deletions DataManager.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#include "DataManager.h"

static void saveReservations(const std::vector<Reservation> &reservations, const std::string &filename)
{
std::ofstream outFile(filename, std::ios::out | std::ios::binary);
if (outFile.is_open())
{
for (const auto &res : reservations)
{
outFile.write((char *)&res, sizeof(res));
}
outFile.close();
}
else
{
std::cerr << "Unable to open file for writing: " << filename << std::endl;
}
}

static std::vector<Reservation> loadReservations(const std::string &filename)
{
std::vector<Reservation> reservations;
std::ifstream inFile(filename, std::ios::in | std::ios::binary);
if (inFile.is_open())
{
Reservation res;
while (inFile.read((char *)&res, sizeof(res)))
{
reservations.push_back(res);
}
inFile.close();
}
else
{
std::cerr << "Unable to open file for reading: " << filename << std::endl;
}
return reservations;
}
static void saveJoueurs(const std::vector<Joueur> &joueurs, const std::string &filename)
{
std::ofstream outFile(filename, std::ios::out | std::ios::binary);
if (outFile.is_open())
{
for (const auto &joueur : joueurs)
{
outFile.write((char *)&joueur, sizeof(joueur));
}
outFile.close();
}
else
{
std::cerr << "Unable to open file for writing: " << filename << std::endl;
}
}

static std::vector<Joueur> loadJoueurs(const std::string &filename)
{
std::vector<Joueur> joueurs;
std::ifstream inFile(filename, std::ios::in | std::ios::binary);
if (inFile.is_open())
{
Joueur joueur;
while (inFile.read((char *)&joueur, sizeof(joueur)))
{
joueurs.push_back(joueur);
}
inFile.close();
}
else
{
std::cerr << "Unable to open file for reading: " << filename << std::endl;
}
return joueurs;
}

static void saveParties(const std::vector<Partie> &parties, const std::string &filename)
{
std::ofstream outFile(filename, std::ios::out | std::ios::binary);
if (outFile.is_open())
{
for (const auto &partie : parties)
{
outFile.write((char *)&partie, sizeof(partie));
}
outFile.close();
}
else
{
std::cerr << "Unable to open file for writing: " << filename << std::endl;
}
}

static std::vector<Partie> loadParties(const std::string &filename)
{
std::vector<Partie> parties;
std::ifstream inFile(filename, std::ios::in | std::ios::binary);
if (inFile.is_open())
{
Partie partie;
while (inFile.read((char *)&partie, sizeof(partie)))
{
parties.push_back(partie);
}
inFile.close();
}
std::cerr << "Unable to open file for writing: " << filename << std::endl;
}
38 changes: 38 additions & 0 deletions GestionClients.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef GESTIONCLIENTS_H
#define GESTIONCLIENTS_H


#include "client.h"
#include <string>
#include <algorithm>
#include <vector>

class GestionClients
{
public:
// Constructor
GestionClients() {}

// Add a client
void ajouterClient(const Client &client);

// Remove a client
bool supprimerClient(const std::string &nom);

// Search for a client
Client *rechercherClient(const std::string &nom) const;

// Display all clients
void afficherClients() const;

// Sort clients by name
void trierClientsParNom();

// Get the list of clients
const std::vector<Client> &getClients() const;

private:
std::vector<Client> clients;
};

#endif
Loading