Vous êtes sur la page 1sur 6

#include <iostream>

#include <fstream>
#include <vector>
#include "Patient.h"
#include "Medecin.h"

// ajouter et stoker dans le fichier "patients.txt"


void ajouterPatient(const Patient& patient) {
std::ofstream fichier("patients.txt", std::ios::app);
if (fichier) {
fichier <<"nom: "<<patient.getNom() << "," << " prénom : "<<patient.getPrenom() << ","
<< "adresse:"<<patient.getAdresse() << "," << "maladie : "<<patient.getMaladie() << "\n";
fichier.close();
std::cout << "Le patient a été ajouté avec succès.\n";
} else {
std::cout << "Erreur lors de l'ouverture du fichier.\n";
}
}

// ajouter un medecin et stoker danslefichier "medecins.txt"


void ajouterMedecin(const Medecin& medecin) {
std::ofstream fichier("medecins.txt", std::ios::app);
if (fichier) {
fichier <<"nom: " <<medecin.getNom() << "," << "prenom :"<<medecin.getPrenom() <<
"," << "adresse :" <<medecin.getAdresse() << ","
<< medecin.getFonction() << "," << medecin.getSpecialite() << "\n";
fichier.close();
std::cout << "Le medecin ajouté avec succès.\n";
} else {
std::cout << "Erreur lors de l'ouverture du fichier.\n";
}
}

int main() {
int choix;
bool ajouterAutre = true;

std::cout << "Bienvenue dans notre app de gestion de l'hôpital.\n";

while (ajouterAutre) {
std::cout << "Que souhaitez-vous faire ?\n";
std::cout << "1. Ajouter un nouveau patient\n";
std::cout << "2. Ajouter un nouveau medecin\n";
std::cout << "3. Quitter le programme\n";
std::cout << "Votre choix : ";
std::cin >> choix;

if (choix == 1) {
std::string nom, prenom, adresse, maladie;
std::cout << "\nAjout d'un nouveau patient :\n";
std::cout << "Nom : ";
std::cin >> nom;
std::cout << "Prenom : ";
std::cin >> prenom;
std::cout << "Adresse : ";
std::cin.ignore();
std::getline(std::cin, adresse);
std::cout << "Maladie : ";
std::getline(std::cin, maladie);

Patient nouveauPatient(nom, prenom, adresse, maladie);


ajouterPatient(nouveauPatient);
} else if (choix == 2) {
std::string nom, prenom, adresse, fonction, specialite;
std::cout << "\nAjout d'un nouveau medecin :\n";
std::cout << "Nom : ";
std::cin >> nom;
std::cout << "Prenom : ";
std::cin >> prenom;
std::cout << "Adresse : ";
std::cin.ignore();
std::getline(std::cin, adresse);

char reponse;
std::cout << "Voulez-vous ajouter ce medecin ? (o/n) : ";
std::cin >> reponse;

if (reponse == 'o' || reponse == 'O') {


std::cout << "Fonction : ";
std::cin.ignore();
std::getline(std::cin, fonction);
std::cout << "Specialite : ";
std::cin.ignore();
std::getline(std::cin, specialite);
Medecin nouveauMedecin(nom, prenom, adresse, fonction, specialite);
ajouterMedecin(nouveauMedecin);
} else {
std::cout << "Medecin non ajouté.\n";
}
} else if (choix == 3) {
ajouterAutre = false;
std::cout << "d'accord Au revoir !\n";
} else {
std::cout << "Choix invalide. Veuillez réessayer.\n";
}
}
return 0;
}

include "Employer.h"

Employe::Employe(const std::string& nom, const std::string& prenom, const std::string&


adresse, const std::string& fonction)
: Personne(nom, prenom, adresse), fonction(fonction) {}

Employe::~Employe() {}

std::string Employe::getFonction() const {


return fonction;
}

#ifndef EMPLOYE_H
#define EMPLOYE_H

#include "Personne.h"

class Employe : public Personne {


protected:
std::string fonction;

public:
Employe(const std::string& nom, const std::string& prenom, const std::string& adresse,
const std::string& fonction);
virtual ~Employe();

std::string getFonction() const;


};

#endif // EMPLOYE_H

#include "Medecin.h"

Medecin::Medecin(const std::string& nom, const std::string& prenom, const std::string&


adresse, const std::string& fonction,
const std::string& specialite)
: Employe(nom, prenom, adresse, fonction), specialite(specialite) {}

Medecin::~Medecin() {}
std::string Medecin::getSpecialite() const {
return specialite;
}

#ifndef MEDECIN_H
#define MEDECIN_H

#include "Employer.h"

class Medecin : public Employe {


private:
std::string specialite;

public:
Medecin(const std::string& nom, const std::string& prenom, const std::string& adresse,
const std::string& fonction,
const std:##:string& specialite);
~Medecin();

std::string getSpecialite() const;


};

#endif // MEDECIN_H

#include "Patient.h"

Patient::Patient(const std::string& nom, const std::string& prenom, const std::string&


adresse, const std::string& maladie)
: Personne(nom, prenom, adresse), maladie(maladie) {}

std::string Patient::getMaladie() const {


return maladie;
}

void Patient::setMaladie(const std::string& maladie) {


this->maladie = maladie;

#ifndef PATIENT_H
#define PATIENT_H

#include <string>
#include "Personne.h"

class Patient : public Personne {


private:
std::string maladie;
}

public:
Patient(const std::string& nom, const std::string& prenom, const std::string& adresse,
const std::string& maladie);

std::string getMaladie() const;


void setMaladie(const std::string& maladie);
};

#endif // PATIENT_H

#include "Personne.h"

Personne::Personne(const std::string& nom, const std::string& prenom, const std::string&


adresse)
: nom(nom), prenom(prenom), adresse(adresse) {}

Personne::~Personne() {}

std::string Personne::getNom() const {


return nom;
}

std::string Personne::getPrenom() const {


return prenom;
}

std::string Personne::getAdresse() const {


return adresse;
}

#ifndef PERSONNE_H
#define PERSONNE_H

#include <string>

class Personne {
protected:
std::string nom;
std::string prenom;
std::string adresse;

public:
Personne(const std::string& nom, const std::string& prenom, const std::string& adresse);
virtual ~Personne();

std::string getNom() const;


std::string getPrenom() const;
std::string getAdresse() const;
};

#endif // PERSONNE_H

Vous aimerez peut-être aussi