diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3a2238d --- /dev/null +++ b/.gitignore @@ -0,0 +1,245 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +[Xx]64/ +[Xx]86/ +[Bb]uild/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml + +# TODO: Un-comment the next line if you do not want to checkin +# your web deploy settings because they may include unencrypted +# passwords +#*.pubxml +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Microsoft Azure ApplicationInsights config file +ApplicationInsights.config + +# Windows Store app package directory +AppPackages/ +BundleArtifacts/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# LightSwitch generated files +GeneratedArtifacts/ +ModelManifest.xml + +# Paket dependency manager +.paket/paket.exe + +# FAKE - F# Make +.fake/ \ No newline at end of file diff --git a/Gescole/Gescole.sln b/Gescole/Gescole.sln new file mode 100644 index 0000000..32eb70a --- /dev/null +++ b/Gescole/Gescole.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25123.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Gescole", "Gescole\Gescole.vcxproj", "{B0DFA3A7-2432-4285-8263-BE098D720D7E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0DFA3A7-2432-4285-8263-BE098D720D7E}.Debug|x64.ActiveCfg = Debug|x64 + {B0DFA3A7-2432-4285-8263-BE098D720D7E}.Debug|x64.Build.0 = Debug|x64 + {B0DFA3A7-2432-4285-8263-BE098D720D7E}.Debug|x86.ActiveCfg = Debug|Win32 + {B0DFA3A7-2432-4285-8263-BE098D720D7E}.Debug|x86.Build.0 = Debug|Win32 + {B0DFA3A7-2432-4285-8263-BE098D720D7E}.Release|x64.ActiveCfg = Release|x64 + {B0DFA3A7-2432-4285-8263-BE098D720D7E}.Release|x64.Build.0 = Release|x64 + {B0DFA3A7-2432-4285-8263-BE098D720D7E}.Release|x86.ActiveCfg = Release|Win32 + {B0DFA3A7-2432-4285-8263-BE098D720D7E}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Gescole/Gescole/Application.cpp b/Gescole/Gescole/Application.cpp new file mode 100644 index 0000000..520e39a --- /dev/null +++ b/Gescole/Gescole/Application.cpp @@ -0,0 +1,143 @@ +#include "Application.h" +#include "Professeur.h" +#include "FormProf.h" +#include +#include +#include +#include"MenuProf.h" + + + +Application::Application() +{ + this->MenuStandart = NULL; +} + + +Application::~Application() +{ +} + +void Application::setMenu(Menu * menuStandart) +{ + if (menuStandart) + { + this->MenuStandart = menuStandart; + } +} + +void Application::run() +{ + this->Again = true; + + Container Professeur; + + do + { + this->MenuStandart->display(cout); + + Controller(this->MenuStandart->askChoice(cout)); + + } while (this->Again); + +} + +void Application::Controller(eMENU mnemo) +{ + switch (mnemo) + { + + case eCREATE: Create(); break; + case eREAD: Read(); break; + case eUPDATE: Update(); break; + case eDELETE: Delete(); break; + case eDELETEALL: DeleteAll(); break; + case eLIST: List(); break; + case eFIRST: First(); break; + case eNEXT: Next(); break; + case eLAST: Last(); break; + case ePREVIOUS: Previous(); break; + case eSORT: Sort(); break; + case eSEARCH: Shearch(); break; + case eERROR: Error(); break; + case eQUIT: Quit(); break; + default: Bydefault(); break; + + } +} + +void Application::Create() +{ + cout << "Create" << endl; +} + +void Application::Read() +{ + cout << "Read" << endl; +} + +void Application::Update() +{ + cout << "Update" << endl; +} + +void Application::Delete() +{ + cout << "Delete" << endl; +} + +void Application::DeleteAll() +{ + cout << "Delete All" << endl; +} + +void Application::List() +{ + cout << "List" << endl; +} + +void Application::First() +{ + cout << "First" << endl; +} + +void Application::Next() +{ + cout << "Next" << endl; +} + +void Application::Last() +{ + cout << "Last" << endl; +} + +void Application::Previous() +{ + cout << "Previous" << endl; +} + +void Application::Sort() +{ + cout << "Sort" << endl; +} + +void Application::Shearch() +{ + cout << "Shearch" << endl; +} + +void Application::Error() +{ + cout << "Error" << endl; +} + +void Application::Quit() +{ + cout << "Quit" << endl; + this->Again = false; +} + +void Application::Bydefault() +{ +} + diff --git a/Gescole/Gescole/Application.h b/Gescole/Gescole/Application.h new file mode 100644 index 0000000..139d2b9 --- /dev/null +++ b/Gescole/Gescole/Application.h @@ -0,0 +1,34 @@ +#pragma once +#include"Menu.h" + +class Application +{ + +protected: + Menu* MenuStandart; + bool Again; + +public: + Application(); + ~Application(); + void setMenu(Menu* menuStandart); + virtual void run(); + virtual void Create(); + virtual void Read(); + virtual void Update(); + virtual void Delete(); + virtual void DeleteAll(); + virtual void List(); + virtual void First(); + virtual void Next(); + virtual void Last(); + virtual void Previous(); + virtual void Sort(); + virtual void Shearch(); + virtual void Error(); + virtual void Quit(); + virtual void Bydefault(); +protected: + virtual void Controller(eMENU mnemo); +}; + diff --git a/Gescole/Gescole/ApplicationProf.cpp b/Gescole/Gescole/ApplicationProf.cpp new file mode 100644 index 0000000..207439a --- /dev/null +++ b/Gescole/Gescole/ApplicationProf.cpp @@ -0,0 +1,49 @@ +#include "ApplicationProf.h" + + +void ApplicationProf::Create() +{ + Temp = new Professeur; + Container_Professeur.Add(Temp); + Frm >> *Temp; + +} + +void ApplicationProf::List() +{ + this->Temp = this->Container_Professeur.First(); + while (this->Temp) + { + Frm << *Temp; + this->Temp = this->Container_Professeur.Next(); + } +} + +void ApplicationProf::First() +{ + this->Temp = this->Container_Professeur.First(); + Frm << *this->Temp; +} + +void ApplicationProf::Next() +{ + this->Temp = this->Container_Professeur.Next(); + Frm << *this->Temp; +} + +void ApplicationProf::Last() +{ + this->Temp = this->Container_Professeur.Last(); + Frm << *this->Temp; +} + +void ApplicationProf::Previous() +{ + this->Temp = this->Container_Professeur.Previous(); + Frm << *this->Temp; +} + +void ApplicationProf::Read() +{ + Frm << *Temp; +} diff --git a/Gescole/Gescole/ApplicationProf.h b/Gescole/Gescole/ApplicationProf.h new file mode 100644 index 0000000..044074f --- /dev/null +++ b/Gescole/Gescole/ApplicationProf.h @@ -0,0 +1,25 @@ +#pragma once +#include"Application.h" +#include"Container.cpp" +#include"Professeur.h" +#include"FormProf.h" +class ApplicationProf + :public Application +{ +protected: + Container Container_Professeur; + FormProf Frm; + Professeur* Temp; + + +public: + void Create(); + void List(); + void First(); + void Next(); + void Last(); + void Previous(); + void Read(); + +}; + diff --git a/Gescole/Gescole/Container.cpp b/Gescole/Gescole/Container.cpp new file mode 100644 index 0000000..ac3abc0 --- /dev/null +++ b/Gescole/Gescole/Container.cpp @@ -0,0 +1,180 @@ +#pragma once +#include "Container.h" +#include "FormProf.h" + +template +Container* Container::idOwner = NULL; +template +double Container::inLife = 0; + +template +const Container& Container::operator=(const Container & other) +{ + return Duplication(other); +} + +template +Container::Container() +{ + if (!idOwner) idOwner = this; + inLife++; +} + +template +Container::Container(const Container & other) +{ + Duplication(other); + inLife++; +} + + +template +Container::~Container() +{ + Flush(); + inLife--; +} + +template +ENTITY * Container::Add(ENTITY * other) +{ + if (!other)return 0; + if (!idOwner) idOwner = this; + if (!isOwner()) idOwner->Add(other); + if (!Find(other)) + { + m_container.push_back(other); + m_it = m_container.end(); + m_it--; + } + + return (*m_it); +} + +template +ENTITY * Container::First() +{ + if (idOwner) + { + if (!m_container.size() && !idOwner)return 0; + m_it = m_container.begin(); + } + + return (*m_it); +} + +template +ENTITY * Container::Last() +{ + if (idOwner) + { + if (!m_container.size() && !idOwner)return 0; + m_it = m_container.end(); + m_it--; + } + + return (*m_it); +} + +template +ENTITY * Container::Next() +{ + if (idOwner) + { + if (!m_container.size() && !idOwner)return 0; + if (m_it == m_container.end() - 1)return 0; + m_it++; + } + + return (*m_it); +} + +template +ENTITY * Container::Previous() +{ + if (idOwner) + { + if (!m_container.size() && !idOwner)return 0; + if (m_it == m_container.begin())return 0; + m_it--; + } + + return (*m_it); +} + +template +Container& Container::Duplication(const Container& other) +{ + if (this == &other) return *this; + if (!other.Size()) return *this; + m_container = other.m_container; + m_it = m_container.begin(); + + while ((*m_it != *other.m_it) && (m_it != other.m_container.end())) m_it++; + + m_it = other.m_it; + return *this; +} + +template +bool Container::Flush() +{ + + if (idOwner==this && inLife == 1) + { + for (m_it = m_container.begin(); m_it != m_container.end(); m_it++) + { + delete *m_it; + } + idOwner = NULL; + + m_container.clear(); + } + + if (idOwner != this) m_container.clear(); + + return (true); +} + +template +size_t Container::Size() const +{ + if (!idOwner) return 0; + return m_container.size(); +} + +template +bool Container::isOwner() +{ + return (idOwner==this); +} + +template +Container * Container::getOwner() +{ + return idOwner; +} + +template +void Container::setMaster() +{ +} + +template +void Container::setOwner() +{ + if (!idOwner || (idOwner && (Size() >= idOwner->Size()))) idOwner = this; +} + +template +ENTITY* Container::Find(ENTITY * other) +{ + + for (m_it = m_container.begin(); m_it != m_container.end(); m_it ++) + { + if (*m_it == other) return *m_it; + } + + return NULL; +} + diff --git a/Gescole/Gescole/Container.h b/Gescole/Gescole/Container.h new file mode 100644 index 0000000..5144a69 --- /dev/null +++ b/Gescole/Gescole/Container.h @@ -0,0 +1,40 @@ +#pragma once + +#include +#include"Professeur.h" +#include +using namespace std; + +template +class Container +{ +public: + const Container& operator=(const Container& other); + Container(); + Container(const Container& other); + ~Container(); + ENTITY* Add(ENTITY* other); + ENTITY* First(); + ENTITY* Last(); + ENTITY* Next(); + ENTITY* Previous(); + Container& Duplication(const Container& other); + bool Flush(); + size_t Size() const; + bool isOwner(); + Container* getOwner(); + void setMaster(); + void setOwner(); + +protected: + ENTITY* Find(ENTITY* other); + + +protected: + static double inLife; + static Container* idOwner; + typename vector m_container; + typename vector::iterator m_it; + +}; + diff --git a/Gescole/Gescole/FormProf.cpp b/Gescole/Gescole/FormProf.cpp new file mode 100644 index 0000000..0fc4207 --- /dev/null +++ b/Gescole/Gescole/FormProf.cpp @@ -0,0 +1,42 @@ +#include "Professeur.h" +#include "FormProf.h" +#include "Message.h" +#include +#include +#include "ZoneSaisie.h" + +using namespace std; + + +void FormProf::operator<<(Professeur& Prof) +{ + if (&Prof) + { + cout << endl; + cout << FRM_PROF_ID << FRM_PROF_DEUXPOINTS << Prof.getId() << endl; + cout << FRM_PROF_NOM << FRM_PROF_DEUXPOINTS << Prof.getNom() << endl; + cout << FRM_PROF_PRENOM << FRM_PROF_DEUXPOINTS << Prof.getPrenom() << endl; + cout << FRM_PROF_ANNEE_NAISSANCE << FRM_PROF_DEUXPOINTS << Prof.getAnneeNaissance() << endl; + cout << FRM_PROF_POIDS << FRM_PROF_DEUXPOINTS << Prof.getPoids_Kg() << endl; + cout << FRM_PROF_SALAIRE << FRM_PROF_DEUXPOINTS << Prof.getSalaireMensuel_Eur() << endl; + cout << "------------------" << endl; + } + +} + +void FormProf::operator>>(Professeur& Prof) +{ + ZoneSaisie zs; + cout << FRM_PROF_NOM << FRM_PROF_DEUXPOINTS << endl; + if (zs.Ask()) Prof.setNom(zs.ValString()); + cout << FRM_PROF_PRENOM << FRM_PROF_DEUXPOINTS << endl; + if (zs.Ask()) Prof.setPrenom(zs.ValString()); + cout << FRM_PROF_ANNEE_NAISSANCE << FRM_PROF_DEUXPOINTS << endl; + if (zs.Ask()) Prof.setAnneeNaissance(zs.ValInt()); + cout << FRM_PROF_POIDS << FRM_PROF_DEUXPOINTS << endl; + if (zs.Ask()) Prof.setPoids_Kg(zs.ValFloat()); + cout << FRM_PROF_SALAIRE << FRM_PROF_DEUXPOINTS << endl; + if (zs.Ask()) Prof.setSalaireMensuel_Eur(zs.ValFloat()); + cout << "------------------" << endl; + +} diff --git a/Gescole/Gescole/FormProf.h b/Gescole/Gescole/FormProf.h new file mode 100644 index 0000000..6dca555 --- /dev/null +++ b/Gescole/Gescole/FormProf.h @@ -0,0 +1,19 @@ +#ifndef FORMPROF_H + +#define FORMPROF_H + +#include "Professeur.h" +#include + +class FormProf +{ +public: + + void operator<<(Professeur& Prof); + void operator>>(Professeur& Prof); + +}; + + + +#endif \ No newline at end of file diff --git a/Gescole/Gescole/Gescole.vcxproj b/Gescole/Gescole/Gescole.vcxproj new file mode 100644 index 0000000..ee0f260 --- /dev/null +++ b/Gescole/Gescole/Gescole.vcxproj @@ -0,0 +1,174 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {B0DFA3A7-2432-4285-8263-BE098D720D7E} + Win32Proj + Gescole + 8.1 + + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + + + + + + + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Gescole/Gescole/Gescole.vcxproj.filters b/Gescole/Gescole/Gescole.vcxproj.filters new file mode 100644 index 0000000..0bfb79c --- /dev/null +++ b/Gescole/Gescole/Gescole.vcxproj.filters @@ -0,0 +1,90 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + Fichiers sources + + + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + Fichiers d%27en-tête + + + \ No newline at end of file diff --git a/Gescole/Gescole/LigneMenu.cpp b/Gescole/Gescole/LigneMenu.cpp new file mode 100644 index 0000000..8fbb46e --- /dev/null +++ b/Gescole/Gescole/LigneMenu.cpp @@ -0,0 +1,60 @@ +#include "LigneMenu.h" + + + + +LigneMenu & LigneMenu::operator=(LigneMenu & source) +{ + if (&source == this) return(*this); + *m_Ligne = *source.m_Ligne, + m_Nemo = source.m_Nemo; + m_Hotkey = source.m_Hotkey; + return (*this); +} + +LigneMenu::LigneMenu() +{ + Initialize(eNULL, ' ', NULL); +} + +LigneMenu::LigneMenu(LigneMenu & source) +{ + + Initialize(source.m_Nemo, source.m_Hotkey, source.m_Ligne->c_str()); +} + +LigneMenu::LigneMenu(eMENU nemo, char hotkey, const char * ligne) +{ + Initialize(nemo,hotkey,ligne); +} + +char LigneMenu::getHockey() +{ + + return m_Hotkey; +} + +eMENU LigneMenu::getNemo() +{ + return m_Nemo; +} + +string * LigneMenu::getLigne() +{ + + return m_Ligne; +} + + + + +LigneMenu::~LigneMenu() +{ +} + +void LigneMenu::Initialize(eMENU nemo, char hotkey, const char * ligne) +{ + m_Ligne = new string(ligne); + m_Nemo = nemo; + m_Hotkey = hotkey; +} diff --git a/Gescole/Gescole/LigneMenu.h b/Gescole/Gescole/LigneMenu.h new file mode 100644 index 0000000..5b81901 --- /dev/null +++ b/Gescole/Gescole/LigneMenu.h @@ -0,0 +1,53 @@ +#pragma once + +// definition des mnemonique; +#include +#include + +using namespace std; +enum eMENU +{ +eNULL=0, +eNONE=0, +eCREATE, +eREAD, +eUPDATE, +eDELETE, +eDELETEALL, +eLIST, +eFIRST, +eNEXT, +eLAST, +ePREVIOUS, +eSORT, +eSEARCH, +eERROR=-1, +eQUIT=999 +}; + +class LigneMenu +{ +public: + LigneMenu& operator=(LigneMenu& source); + LigneMenu(); + LigneMenu(LigneMenu& source); + LigneMenu(eMENU nemo,char hotkey, const char* ligne); + char getHockey(); + eMENU getNemo(); + string* getLigne(); + + + ~LigneMenu(); + + +protected: + string* m_Ligne; + char m_Hotkey; + eMENU m_Nemo; + + void Initialize(eMENU nemo, char hotkey, const char* ligne); + + + +}; + diff --git a/Gescole/Gescole/Main.cpp b/Gescole/Gescole/Main.cpp new file mode 100644 index 0000000..fbeb2f0 --- /dev/null +++ b/Gescole/Gescole/Main.cpp @@ -0,0 +1,81 @@ +#include"MenuProf.h" +#include"ApplicationProf.h" +#include +#include +#include"MultiType.h" + + +using namespace std; + + +#pragma warning (disable:4996) + + +void main(void) +{ + + + + + + + + + + + + + + + + + + + //// Test Stream + // + //Professeur prof; + //FormProf frm; + //fstream fileprof; + //Multi_Type buffeur; + // + //frm >> prof; + + + //fileprof.open("Prof.dat", + // ios_base::binary | + // ios_base::in | + // ios_base::out | + // ios_base::trunc); + //if (!fileprof.good()) + //{ + // cout << "Erreur de fichier" << endl; + // return; + //} + // + //fileprof.clear(); + + //buffeur.ul = prof.getId(); + //fileprof.write((char*)&buffeur, sizeof (unsigned long)); + //fileprof.write((char*)prof.getNom(), sizeof(prNOMLEN)); + //fileprof.write((char*)prof.getPrenom(), sizeof(prPRENOMLEN)); + //buffeur.f = prof.getPoids_Kg(); + //fileprof.write((char*)&buffeur, sizeof(float)); + //buffeur.f = prof.getSalaireMensuel_Eur(); + //fileprof.write((char*)&buffeur, sizeof(float)); + // + + //fileprof.close(); + + + + + + + + /*MenuProf profmenu; + ApplicationProf AppProf; + + AppProf.setMenu(&profmenu); + AppProf.run();*/ + +} diff --git a/Gescole/Gescole/Menu.cpp b/Gescole/Gescole/Menu.cpp new file mode 100644 index 0000000..3de3d31 --- /dev/null +++ b/Gescole/Gescole/Menu.cpp @@ -0,0 +1,98 @@ +#include "Menu.h" +#include"ZoneSaisie.h" + +Menu::Menu() + :Container() +{ + m_title = new string; + setTitle(""); + m_choice = eNULL; +} + +Menu::Menu(char * title) + :Container() +{ + m_title = new string; + setTitle(title); + m_choice = eNULL; + +} + +Menu::Menu(const Menu & other) + : Container(other) +{ + if (this == &other) return; + m_title = new string; + setTitle(other.m_title->c_str()); + m_choice = other.m_choice; +} + +Menu::~Menu() +{ + delete m_title; +} + +Menu & Menu::operator=(Menu & other) +{ + if (this == &other)return *this; + Container::operator=(other); + *m_title = *other.m_title; + m_choice = other.m_choice; + return *this; +} + + + +const char * Menu::getTitle() const +{ + return (m_title->c_str()); +} + +void Menu::setTitle(const char * Title) +{ + *m_title = Title; +} + +void Menu::display(ostream & COUT) +{ + LigneMenu* temp_Menu; + + COUT << getTitle() << endl; + temp_Menu = First(); + while (temp_Menu) + { + COUT << "\t" << temp_Menu->getHockey() << " - " << *(temp_Menu->getLigne()) << endl; + temp_Menu = Next(); + } + +} + +eMENU Menu::askChoice(ostream & COUT) +{ + ZoneSaisie zs; + do + { + COUT << "Votre choix: "; + } + while (!zs.Ask() || translateHotkey(zs.ValCharUpper())== eNULL); // doit introduire au moins 1 caractere. + + return m_choice; + +} + +eMENU Menu::translateHotkey(char hotkey) +{ + LigneMenu* temp; + temp = First(); + + while (temp && (temp->getHockey() != hotkey)) + { + temp = Next(); + } + + if (temp) m_choice = temp->getNemo(); + else m_choice = eNULL; + + return m_choice; +} + diff --git a/Gescole/Gescole/Menu.h b/Gescole/Gescole/Menu.h new file mode 100644 index 0000000..ae6159e --- /dev/null +++ b/Gescole/Gescole/Menu.h @@ -0,0 +1,29 @@ +#pragma once +#include +#include"LigneMenu.h" +#include +#include"Container.cpp" + +class Menu: public Container +{ + +protected: + string* m_title;// titre du menu + eMENU m_choice;//choix fait dans le menu + + + +public: + Menu(); // sans paramettre + Menu(char* title); // avec paramettre + Menu(const Menu& other); // recopie + ~Menu(); // Destructeur + Menu& operator=(Menu& other); // copie + + const char* getTitle() const; + void setTitle(const char* Title); + void display(ostream& COUT); + eMENU askChoice(ostream & COUT); + eMENU translateHotkey(char hotkey); +}; + diff --git a/Gescole/Gescole/MenuCours.cpp b/Gescole/Gescole/MenuCours.cpp new file mode 100644 index 0000000..63fc185 --- /dev/null +++ b/Gescole/Gescole/MenuCours.cpp @@ -0,0 +1,19 @@ +#include "MenuCours.h" + + + +MenuCours::MenuCours() +{ + setTitle("Menu des Cours"); + + Add(new LigneMenu(eCREATE, 'C', "Cree un Cours.")); + Add(new LigneMenu(eREAD, 'A', "Afficher le Cours courant.")); + Add(new LigneMenu(eUPDATE, 'M', "Modifier le Cours.")); + Add(new LigneMenu(eDELETE, 'E', "Effacer le Cours courant.")); + Add(new LigneMenu(eFIRST, 'P', "Aller au premier Cours.")); + Add(new LigneMenu(eNEXT, 'S', "Aller au Cours suivant.")); + Add(new LigneMenu(ePREVIOUS, 'R', "Aller au Cours precedent.")); + Add(new LigneMenu(eLAST, 'D', "Aller au dernier Cours.")); + Add(new LigneMenu(eQUIT, 'Q', "Quitter.")); +} + diff --git a/Gescole/Gescole/MenuCours.h b/Gescole/Gescole/MenuCours.h new file mode 100644 index 0000000..ca4cc67 --- /dev/null +++ b/Gescole/Gescole/MenuCours.h @@ -0,0 +1,9 @@ +#pragma once +#include "Menu.h" +class MenuCours : + public Menu +{ +public: + MenuCours(); +}; + diff --git a/Gescole/Gescole/MenuProf.cpp b/Gescole/Gescole/MenuProf.cpp new file mode 100644 index 0000000..30a7b6f --- /dev/null +++ b/Gescole/Gescole/MenuProf.cpp @@ -0,0 +1,20 @@ +#include "MenuProf.h" + + + +MenuProf::MenuProf() + :Menu() +{ + setTitle("Menu des Professeur"); + + Add(new LigneMenu(eCREATE, 'C', "Cree un prof.")); + Add(new LigneMenu(eREAD, 'A', "Afficher le prof courant.")); + Add(new LigneMenu(eUPDATE, 'M', "Modifier le prof.")); + Add(new LigneMenu(eDELETE, 'E', "Effacer le prof courant.")); + Add(new LigneMenu(eFIRST, 'P', "Aller au premier prof.")); + Add(new LigneMenu(eNEXT, 'S', "Aller au prof suivant.")); + Add(new LigneMenu(ePREVIOUS, 'R', "Aller au prof precedent.")); + Add(new LigneMenu(eLAST, 'D', "Aller au dernier prof.")); + Add(new LigneMenu(eLIST, 'L', "Lister les prof.")); + Add(new LigneMenu(eQUIT, 'Q', "Quitter.")); +} diff --git a/Gescole/Gescole/MenuProf.h b/Gescole/Gescole/MenuProf.h new file mode 100644 index 0000000..e1ffb37 --- /dev/null +++ b/Gescole/Gescole/MenuProf.h @@ -0,0 +1,8 @@ +#pragma once +#include "Menu.h" +class MenuProf : public Menu +{ +public: + MenuProf(); +}; + diff --git a/Gescole/Gescole/Message.h b/Gescole/Gescole/Message.h new file mode 100644 index 0000000..200b7b2 --- /dev/null +++ b/Gescole/Gescole/Message.h @@ -0,0 +1,44 @@ +#ifndef MESSAGE_H +#define MESSAGE_H + +#define LANG_FR + +#ifdef LANG_FR + +#define FRM_PROF_EN_VIE "en vie" +#define FRM_PROF_DEUXPOINTS ": " +#define FRM_PROF_TITRE_CLASS "Professeur" +#define FRM_PROF_INCONNU "Inconnu" +#define FRM_PROF_ID "ID" +#define FRM_PROF_NOM "Nom" +#define FRM_PROF_PRENOM "Prenom" +#define FRM_PROF_ANNEE_NAISSANCE "Date de naissance" +#define FRM_PROF_POIDS "Poids" +#define FRM_PROF_SALAIRE "Salaire" +#define FRM_PROF_SUPPRIME "Supprime" + + + +#endif // LANGUE == FR + +#ifdef LANG_EN + +#define FRM_PROF_EN_VIE "in life" +#define FRM_PROF_DEUXPOINTS ": " +#define FRM_PROF_TITRE_CLASS "Professeur" +#define FRM_PROF_INCONNU "Inconnu" +#define FRM_PROF_ID "ID" +#define FRM_PROF_NOM "Last Name" +#define FRM_PROF_PRENOM "First Name" +#define FRM_PROF_ANNEE_NAISSANCE "Year of birth" +#define FRM_PROF_POIDS "Weight" +#define FRM_PROF_SALAIRE "Salary" +#define FRM_PROF_SUPPRIME "Delete" + + +#endif // LANGUE == EN + + + + +#endif // !MESSAGE_H diff --git a/Gescole/Gescole/MultiType.h b/Gescole/Gescole/MultiType.h new file mode 100644 index 0000000..3e54c6e --- /dev/null +++ b/Gescole/Gescole/MultiType.h @@ -0,0 +1,11 @@ +typedef union Multi_Type +{ + char str[120]; // chaine de 120 char. + long l; + unsigned long ul; + int i; + unsigned int ui; + float f; + double d; + void* p; +}; Multi_Type; \ No newline at end of file diff --git a/Gescole/Gescole/Professeur.cpp b/Gescole/Gescole/Professeur.cpp new file mode 100644 index 0000000..d7dd6dc --- /dev/null +++ b/Gescole/Gescole/Professeur.cpp @@ -0,0 +1,184 @@ +#include "Professeur.h" +#include +#include +#include "Message.h" + +#define DEBUG ON + +#pragma warning (disable:4996) + +using namespace std; + +#define prNOMLEN 50 +#define prPRENOMLEN 50 + +unsigned long Professeur::EnVie = 0; +unsigned long Professeur::Compteur = 0; + +//----------Constructeur---------- +Professeur::Professeur(void) +{ + + InitProfesseur(NULL, FRM_PROF_INCONNU, 1900, 0, 0); + +} + +//----------Constructeur de recopie---------- +Professeur::Professeur(Professeur& Prof) +{ + if (&Prof == this) return; + InitProfesseur(Prof.Nom, Prof.Prenom, Prof.AnneeNaissance, Prof.SalaireMensuel_Eur, Prof.Poids_Kg); +} + +//----------Constructeur avec parametre---------- +Professeur::Professeur(const char* nom,const char* prenom, unsigned int anneenaissance, float salairemensuel_eur, float poids_kg) +{ + + InitProfesseur(nom, prenom, anneenaissance, salairemensuel_eur, poids_kg); + +} + +//----------Destructeur---------- +Professeur::~Professeur(void) +{ + +#ifdef DEBUG ON + cout << FRM_PROF_SUPPRIME << FRM_PROF_DEUXPOINTS << endl; +#endif // DEBUG + + EnVie--; + +#ifdef DEBUG ON + cout << FRM_PROF_TITRE_CLASS << EnVie << endl; +#endif // DEBUG + + delete[] Nom; + delete[] Prenom; +} + +//----------Accesseurs---------- +void Professeur::setNom (const char* nom) +{ + if (!nom) { *Nom = 0; return; } + strncpy(Nom,nom,prNOMLEN); + Nom[prNOMLEN - 1] = 0; + +} + +void Professeur::setPrenom (const char* prenom) +{ + if (!prenom) { *Prenom = 0; return; } + + strcpy(Prenom, prenom); + Prenom[prNOMLEN - 1] = 0; + +} + +void Professeur::setAnneeNaissance (unsigned int anneenaissance) +{ + + if (anneenaissance <= 99) anneenaissance+=1900; + + AnneeNaissance = anneenaissance; +} + +void Professeur::setSalaireMensuel_Eur (float salairemensuel_eur) +{ + if (salairemensuel_eur < 0) salairemensuel_eur = -salairemensuel_eur; + if (salairemensuel_eur > 1000) salairemensuel_eur = 1000; + + SalaireMensuel_Eur = salairemensuel_eur; +} + +void Professeur::setPoids_Kg (float poids_kg) +{ + if (poids_kg < 0) poids_kg = -poids_kg; + if (poids_kg > 200) poids_kg = 200; + + Poids_Kg = poids_kg; +} + +unsigned long Professeur::getId(void) +{ + return (idProfesseur); +} + +const char* Professeur::getNom(void) +{ +return (Nom); +} + +const char* Professeur::getPrenom(void) +{ +return (Prenom); +} + +unsigned int Professeur::getAnneeNaissance(void) +{ +return (AnneeNaissance); +} + +float Professeur::getSalaireMensuel_Eur(void) +{ +return (SalaireMensuel_Eur); +} + +float Professeur::getPoids_Kg(void) +{ +return (Poids_Kg); +} + +//----------Operateurs---------- + +Professeur & Professeur::operator=(Professeur & prof) +{ + if (&prof == this) return (*this); + + idProfesseur = prof.idProfesseur; + setNom(prof.Nom); + setPrenom(prof.Prenom); + setAnneeNaissance(prof.AnneeNaissance); + setPoids_Kg(prof.Poids_Kg); + setSalaireMensuel_Eur(prof.SalaireMensuel_Eur); + + return (*this); +} + +void Professeur::Display(Professeur Prof) +{ + cout << FRM_PROF_ID << FRM_PROF_DEUXPOINTS << Prof.getId() << endl; + cout << FRM_PROF_NOM << FRM_PROF_DEUXPOINTS << Prof.getNom() << endl; + cout << FRM_PROF_PRENOM << FRM_PROF_DEUXPOINTS << Prof.getPrenom() << endl; + cout << FRM_PROF_ANNEE_NAISSANCE << FRM_PROF_DEUXPOINTS << Prof.getAnneeNaissance() << endl; + cout << FRM_PROF_POIDS << FRM_PROF_DEUXPOINTS << Prof.getPoids_Kg() << endl; + cout << FRM_PROF_SALAIRE << FRM_PROF_DEUXPOINTS << Prof.getSalaireMensuel_Eur() << endl; + cout << "------------------" << endl; +} + +void Professeur::InitProfesseur(const char * nom, const char * prenom, unsigned int anneenaissance, float salairemensuel_eur, float poids_kg) +{ + + char buf_Nom[prNOMLEN]; // pour concatenation du nom avant l'envoi dans le seteur + Compteur++; + EnVie++; + idProfesseur = Compteur; + sprintf(buf_Nom, "%s%04d",FRM_PROF_TITRE_CLASS, idProfesseur); + + // Création de variable en allocation dinamique + Nom = new char[prNOMLEN]; + Prenom = new char[prPRENOMLEN]; + + // Vider memoire allouée pour etre sur de ce qu'on va trouver a l'interieur. + memset(Nom, 0, prNOMLEN*sizeof(char)); + memset(Prenom, 0, prPRENOMLEN*sizeof(char)); + + if (!nom) setNom(buf_Nom); + else setNom(nom); + + setPrenom(prenom); + setAnneeNaissance(anneenaissance); + setPoids_Kg(poids_kg); + setSalaireMensuel_Eur(salairemensuel_eur); + + cout << FRM_PROF_TITRE_CLASS <<" [" << EnVie << "] " << FRM_PROF_EN_VIE << "." << endl; +} diff --git a/Gescole/Gescole/Professeur.h b/Gescole/Gescole/Professeur.h new file mode 100644 index 0000000..7cee016 --- /dev/null +++ b/Gescole/Gescole/Professeur.h @@ -0,0 +1,53 @@ +#ifndef PROFESSEUR_H +#include + +#define PROFESSEUR_H + +#define prNOMLEN 50 +#define prPRENOMLEN 50 + +class Professeur +{ +protected: + + static unsigned long EnVie; // compteur de vie + static unsigned long Compteur; // compteur d'ID objets + unsigned long idProfesseur; + char* Nom; + char* Prenom; + unsigned int AnneeNaissance; + float SalaireMensuel_Eur; + float Poids_Kg; + +public: + Professeur(void);// Constructeur sans paramettres + Professeur(Professeur& prof);// Constructeur sans paramettres + Professeur(const char* nom,const char* prenom, unsigned int anneenaissance, float salairemensuel_eur, float poids_kg);// Constructeur sans paramettres + + ~Professeur(void);// Destructeur sans paramettres + + void setNom (const char* nom); + void setPrenom (const char* prenom); + void setAnneeNaissance (unsigned int anneenaissance); + void setSalaireMensuel_Eur (float salairemensuel_eur); + void setPoids_Kg (float poids_kg); + + unsigned long getId(void); + const char* getNom(void); + const char* getPrenom(void); + unsigned int getAnneeNaissance(void); + float getSalaireMensuel_Eur(void); + float getPoids_Kg(void); + + Professeur& operator = (Professeur& prof); + + void Display(Professeur Prof); + +protected: + void InitProfesseur(const char* nom, const char* prenom, unsigned int anneenaissance, float salairemensuel_eur, float poids_kg);// Constructeur sans paramettres + + + +} ; + +#endif \ No newline at end of file diff --git a/Gescole/Gescole/ZoneSaisie.cpp b/Gescole/Gescole/ZoneSaisie.cpp new file mode 100644 index 0000000..a50abef --- /dev/null +++ b/Gescole/Gescole/ZoneSaisie.cpp @@ -0,0 +1,63 @@ +#include "ZoneSaisie.h" +#include +#include + +using namespace std; + +#define prNOMLEN 50 +#define prPRENOMLEN 50 + +ZoneSaisie::ZoneSaisie() +{ +} + + +ZoneSaisie::~ZoneSaisie() +{ +} + +char ZoneSaisie::Ask(void) +{ + + getline(cin, *this); + pbuf = c_str(); + + return pbuf[0]; +} + +const char * ZoneSaisie::ValString(void) +{ + return pbuf; +} + +char ZoneSaisie::ValChar(void) +{ + return pbuf[0]; +} + +char ZoneSaisie::ValCharUpper(void) +{ + + return toupper(ValChar()); +} + +char ZoneSaisie::ValCharLower(void) +{ + return tolower(ValChar()); +} + +int ZoneSaisie::ValInt(void) +{ + return (int)atoi(pbuf); +} + +float ZoneSaisie::ValFloat(void) +{ + return (float)atof(pbuf); +} + +unsigned int ZoneSaisie::ValUInt(void) +{ + return (unsigned int)atoi(pbuf); +} + diff --git a/Gescole/Gescole/ZoneSaisie.h b/Gescole/Gescole/ZoneSaisie.h new file mode 100644 index 0000000..517c971 --- /dev/null +++ b/Gescole/Gescole/ZoneSaisie.h @@ -0,0 +1,26 @@ +#pragma once +#include +using namespace std; + +class ZoneSaisie:public string +{ + +protected: + const char* pbuf; + +public: + ZoneSaisie(); + ~ZoneSaisie(); + char Ask(void); + const char* ValString(void); + char ValChar(void); + char ValCharUpper(void); + char ValCharLower(void); + int ValInt(void); + float ValFloat(void); + unsigned int ValUInt(void); + + + +}; +