Ajouter user.h

This commit is contained in:
2026-02-20 15:12:09 +00:00
parent 23d935f1c1
commit ad915bd439

62
user.h Normal file
View File

@@ -0,0 +1,62 @@
#ifndef USER_H
#define USER_H
#include <iostream>
#include <string>
#include <vector>
// Classe de base (Abstraite)
class User {
protected:
int id;
std::string username;
std::string role;
public:
User(int id, std::string name, std::string r) : id(id), username(name), role(r) {}
// Cette fonction sera différente pour chaque rôle
virtual void showMenu() = 0;
std::string getUsername() { return username; }
virtual ~User() {}
};
// --- Rôle ETUDIANT ---
class Student : public User {
public:
Student(int id, std::string name) : User(id, name, "Student") {}
void showMenu() override {
std::cout << "\n=== MENU ETUDIANT (" << username << ") ===" << std::endl;
std::cout << "1. Voir mes notes" << std::endl;
std::cout << "2. Contacter un prof" << std::endl;
std::cout << "0. Deconnexion" << std::endl;
}
};
// --- Rôle PROFESSEUR ---
class Prof : public User {
public:
Prof(int id, std::string name) : User(id, name, "Prof") {}
void showMenu() override {
std::cout << "\n=== MENU PROFESSEUR (" << username << ") ===" << std::endl;
std::cout << "1. Modifier une note" << std::endl;
std::cout << "2. Liste des etudiants" << std::endl;
std::cout << "0. Deconnexion" << std::endl;
}
};
// --- Rôle ADMIN ---
class Admin : public User {
public:
Admin(int id, std::string name) : User(id, name, "Admin") {}
void showMenu() override {
std::cout << "\n=== MENU ADMIN (" << username << ") ===" << std::endl;
std::cout << "1. Ajouter un utilisateur" << std::endl;
std::cout << "2. Supprimer un utilisateur" << std::endl;
std::cout << "3. Exporter les donnees (TXT)" << std::endl;
std::cout << "0. Deconnexion" << std::endl;
}
};
#endif