From 7493367116c1eb5c98ee3ca54d6f2699f7b98b6f Mon Sep 17 00:00:00 2001 From: Freitas_Enzo Date: Fri, 20 Feb 2026 15:15:19 +0000 Subject: [PATCH] =?UTF-8?q?T=C3=A9l=C3=A9verser=20les=20fichiers=20vers=20?= =?UTF-8?q?"/"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 20 ++++++++++++++++++++ Database.cpp | 33 +++++++++++++++++++++++++++++++++ Database.h | 27 +++++++++++++++++++++++++++ README.md | 18 ++++++++++++++++++ main.cpp | 31 +++++++++++++++++++++++++++++++ 5 files changed, 129 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 Database.cpp create mode 100644 Database.h create mode 100644 README.md create mode 100644 main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..61e0bb1 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.25) +project(StudentManagementSystem) + +set(CMAKE_CXX_STANDARD 17) + +add_executable(StudentManagementSystem + main.cpp + + models/User.cpp + models/Student.cpp + models/Professor.cpp + models/Admin.cpp + models/Course.cpp + models/Grade.cpp + + database/Database.cpp + + services/AuthService.cpp + services/ExportService.cpp +) \ No newline at end of file diff --git a/Database.cpp b/Database.cpp new file mode 100644 index 0000000..c278b72 --- /dev/null +++ b/Database.cpp @@ -0,0 +1,33 @@ +#include "Database.h" +#include "../models/Student.h" +#include "../models/Professor.h" +#include "../models/Admin.h" +#include + +Database::Database() : isConnected(false) {} + +Database::~Database() { disconnect(); } + +bool Database::connect(const std::string& host, + const std::string& user, + const std::string& password, + const std::string& dbName) { + std::cout << "Connexion à la base de données simulée sur " << host << "...\n"; + isConnected = true; + return isConnected; +} + +void Database::disconnect() { + if (isConnected) { + std::cout << "Déconnexion de la base de données.\n"; + isConnected = false; + } +} + +std::vector Database::getAllUsers() { + std::vector users; + users.push_back(new Admin(1, "admin", "hash_admin")); + users.push_back(new Professor(2, "prof", "hash_prof")); + users.push_back(new Student(3, "student", "hash_student", "student@email.com")); + return users; +} diff --git a/Database.h b/Database.h new file mode 100644 index 0000000..ed81efb --- /dev/null +++ b/Database.h @@ -0,0 +1,27 @@ +#ifndef DATABASE_H +#define DATABASE_H + +#include +#include +#include +#include "../models/User.h" + +class Database { +public: + Database(); + ~Database(); + + bool connect(const std::string& host, + const std::string& user, + const std::string& password, + const std::string& dbName); + + void disconnect(); + + std::vector getAllUsers(); + +private: + bool isConnected; +}; + +#endif diff --git a/README.md b/README.md new file mode 100644 index 0000000..9c2cd01 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +Student Management System +Projet réalisé en C++ dans le cadre du BTS CIEL. + +Description +Ce projet simule un système de gestion d’étudiants avec : + + Gestion des utilisateurs (Admin, Professeur, Étudiant) + +AuthentificationSimulation de base de donnéesExport des données vers un fichier texteArchitecture organisée en dossiers (models, services, database) +Structure du projet +models/ → classes User, Student, Professor, Admin, Course, Grade +services/ → AuthService, ExportServicedatabase/ → Databasemain.cpp → Point d’entrée du programmeCMakeLists.txt → Configuration du build +Compilation +```bash +mkdir build +cd build +cmake .. +make \ No newline at end of file diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..039a5ad --- /dev/null +++ b/main.cpp @@ -0,0 +1,31 @@ +#include +#include "database/Database.h" +#include "services/AuthService.h" +#include "services/ExportService.h" + +int main() { + Database db; + db.connect("localhost", "root", "password", "studentdb"); + + std::string username; + std::string password; + + std::cout << "Username: "; + std::cin >> username; + std::cout << "Password: "; + std::cin >> password; + + User* user = AuthService::login(db, username, password); + + if (user) { + std::cout << "\nConnexion réussie.\n"; + user->displayMenu(); + + ExportService::exportData(user); + } else { + std::cout << "Connexion échouée.\n"; + } + + db.disconnect(); + return 0; +} \ No newline at end of file