Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

td4

  • Loading branch information...
commit b18013630eda5a2085e00a75849fc8b75b25a4b9 1 parent 4adbf57
@trecouvr trecouvr authored
View
3  .gitignore
@@ -1,2 +1,5 @@
*.exe
*~
+
+bin/
+obj/
View
18 TD04/TD04.pro
@@ -1,18 +0,0 @@
-#-------------------------------------------------
-#
-# Project created by QtCreator 2012-04-06T14:40:01
-#
-#-------------------------------------------------
-
-QT += core
-
-QT -= gui
-
-TARGET = TD04
-CONFIG += console
-CONFIG -= app_bundle
-
-TEMPLATE = app
-
-
-SOURCES += main.cpp
View
207 TD04/TD04.pro.user
@@ -1,207 +0,0 @@
-<!DOCTYPE QtCreatorProject>
-<qtcreator>
- <data>
- <variable>ProjectExplorer.Project.ActiveTarget</variable>
- <value type="int">0</value>
- </data>
- <data>
- <variable>ProjectExplorer.Project.EditorSettings</variable>
- <valuemap type="QVariantMap">
- <value key="EditorConfiguration.AutoIndent" type="bool">true</value>
- <value key="EditorConfiguration.AutoSpacesForTabs" type="bool">false</value>
- <value key="EditorConfiguration.Codec" type="QByteArray">System</value>
- <value key="EditorConfiguration.DoubleIndentBlocks" type="bool">false</value>
- <value key="EditorConfiguration.IndentBraces" type="bool">false</value>
- <value key="EditorConfiguration.IndentSize" type="int">4</value>
- <value key="EditorConfiguration.MouseNavigation" type="bool">true</value>
- <value key="EditorConfiguration.PaddingMode" type="int">1</value>
- <value key="EditorConfiguration.ScrollWheelZooming" type="bool">true</value>
- <value key="EditorConfiguration.SmartBackspace" type="bool">false</value>
- <value key="EditorConfiguration.SpacesForTabs" type="bool">true</value>
- <value key="EditorConfiguration.TabKeyBehavior" type="int">0</value>
- <value key="EditorConfiguration.TabSize" type="int">8</value>
- <value key="EditorConfiguration.UseGlobal" type="bool">true</value>
- <value key="EditorConfiguration.Utf8BomBehavior" type="int">1</value>
- <value key="EditorConfiguration.addFinalNewLine" type="bool">true</value>
- <value key="EditorConfiguration.cleanIndentation" type="bool">true</value>
- <value key="EditorConfiguration.cleanWhitespace" type="bool">true</value>
- <value key="EditorConfiguration.inEntireDocument" type="bool">false</value>
- </valuemap>
- </data>
- <data>
- <variable>ProjectExplorer.Project.Target.0</variable>
- <valuemap type="QVariantMap">
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Desktop</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Desktop</value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Target.DesktopTarget</value>
- <value key="ProjectExplorer.Target.ActiveBuildConfiguration" type="int">0</value>
- <value key="ProjectExplorer.Target.ActiveDeployConfiguration" type="int">0</value>
- <value key="ProjectExplorer.Target.ActiveRunConfiguration" type="int">0</value>
- <valuemap key="ProjectExplorer.Target.BuildConfiguration.0" type="QVariantMap">
- <value key="ProjectExplorer.BuildCOnfiguration.ToolChain" type="QString">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit.</value>
- <valuemap key="ProjectExplorer.BuildConfiguration.BuildStepList.0" type="QVariantMap">
- <valuemap key="ProjectExplorer.BuildStepList.Step.0" type="QVariantMap">
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">qmake</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
- <value key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary" type="bool">false</value>
- <value key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QString"></value>
- <value key="QtProjectManager.QMakeBuildStep.QMakeForced" type="bool">false</value>
- </valuemap>
- <valuemap key="ProjectExplorer.BuildStepList.Step.1" type="QVariantMap">
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Make</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
- <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
- <value key="Qt4ProjectManager.MakeStep.MakeArguments" type="QString"></value>
- <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
- </valuemap>
- <value key="ProjectExplorer.BuildStepList.StepsCount" type="int">2</value>
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Compiler</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.BuildSteps.Build</value>
- </valuemap>
- <valuemap key="ProjectExplorer.BuildConfiguration.BuildStepList.1" type="QVariantMap">
- <valuemap key="ProjectExplorer.BuildStepList.Step.0" type="QVariantMap">
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Make</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
- <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
- <value key="Qt4ProjectManager.MakeStep.MakeArguments" type="QString">clean</value>
- <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
- </valuemap>
- <value key="ProjectExplorer.BuildStepList.StepsCount" type="int">1</value>
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Nettoyer</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.BuildSteps.Clean</value>
- </valuemap>
- <value key="ProjectExplorer.BuildConfiguration.BuildStepListCount" type="int">2</value>
- <value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
- <valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Qt dans le PATH Release</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
- <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">0</value>
- <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">/home/thomas/Programmation/LO21/TD04-build-desktop</value>
- <value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">2</value>
- <value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="QString">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit.</value>
- <value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
- </valuemap>
- <valuemap key="ProjectExplorer.Target.BuildConfiguration.1" type="QVariantMap">
- <value key="ProjectExplorer.BuildCOnfiguration.ToolChain" type="QString">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit.</value>
- <valuemap key="ProjectExplorer.BuildConfiguration.BuildStepList.0" type="QVariantMap">
- <valuemap key="ProjectExplorer.BuildStepList.Step.0" type="QVariantMap">
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">qmake</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
- <value key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary" type="bool">false</value>
- <value key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QString"></value>
- <value key="QtProjectManager.QMakeBuildStep.QMakeForced" type="bool">false</value>
- </valuemap>
- <valuemap key="ProjectExplorer.BuildStepList.Step.1" type="QVariantMap">
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Make</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
- <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
- <value key="Qt4ProjectManager.MakeStep.MakeArguments" type="QString"></value>
- <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
- </valuemap>
- <value key="ProjectExplorer.BuildStepList.StepsCount" type="int">2</value>
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Compiler</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.BuildSteps.Build</value>
- </valuemap>
- <valuemap key="ProjectExplorer.BuildConfiguration.BuildStepList.1" type="QVariantMap">
- <valuemap key="ProjectExplorer.BuildStepList.Step.0" type="QVariantMap">
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Make</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
- <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
- <value key="Qt4ProjectManager.MakeStep.MakeArguments" type="QString">clean</value>
- <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
- </valuemap>
- <value key="ProjectExplorer.BuildStepList.StepsCount" type="int">1</value>
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Nettoyer</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.BuildSteps.Clean</value>
- </valuemap>
- <value key="ProjectExplorer.BuildConfiguration.BuildStepListCount" type="int">2</value>
- <value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
- <valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Qt dans le PATH Debug</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
- <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
- <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">/home/thomas/Programmation/LO21/TD04-build-desktop</value>
- <value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">2</value>
- <value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="QString">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit.</value>
- <value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
- </valuemap>
- <value key="ProjectExplorer.Target.BuildConfigurationCount" type="int">2</value>
- <valuemap key="ProjectExplorer.Target.DeployConfiguration.0" type="QVariantMap">
- <valuemap key="ProjectExplorer.BuildConfiguration.BuildStepList.0" type="QVariantMap">
- <value key="ProjectExplorer.BuildStepList.StepsCount" type="int">0</value>
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Déploiement</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.BuildSteps.Deploy</value>
- </valuemap>
- <value key="ProjectExplorer.BuildConfiguration.BuildStepListCount" type="int">1</value>
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Pas de déploiement</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.DefaultDeployConfiguration</value>
- </valuemap>
- <value key="ProjectExplorer.Target.DeployConfigurationCount" type="int">1</value>
- <valuemap key="ProjectExplorer.Target.RunConfiguration.0" type="QVariantMap">
- <valuelist key="Analyzer.Valgrind.AddedSupressionFiles" type="QVariantList"/>
- <value key="Analyzer.Valgrind.FilterExternalIssues" type="bool">true</value>
- <value key="Analyzer.Valgrind.NumCallers" type="int">25</value>
- <valuelist key="Analyzer.Valgrind.RemovedSupressionFiles" type="QVariantList"/>
- <value key="Analyzer.Valgrind.TrackOrigins" type="bool">true</value>
- <value key="Analyzer.Valgrind.ValgrindExecutable" type="QString">valgrind</value>
- <valuelist key="Analyzer.Valgrind.VisibleErrorKinds" type="QVariantList">
- <value type="int">0</value>
- <value type="int">1</value>
- <value type="int">2</value>
- <value type="int">3</value>
- <value type="int">4</value>
- <value type="int">5</value>
- <value type="int">6</value>
- <value type="int">7</value>
- <value type="int">8</value>
- <value type="int">9</value>
- <value type="int">10</value>
- <value type="int">11</value>
- <value type="int">12</value>
- <value type="int">13</value>
- <value type="int">14</value>
- </valuelist>
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">TD04</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4RunConfiguration</value>
- <value key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase" type="int">2</value>
- <value key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments" type="QString"></value>
- <value key="Qt4ProjectManager.Qt4RunConfiguration.ProFile" type="QString">TD04.pro</value>
- <value key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix" type="bool">false</value>
- <value key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal" type="bool">false</value>
- <valuelist key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges" type="QVariantList"/>
- <value key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory" type="QString"></value>
- <value key="RunConfiguration.QmlDebugServerPort" type="uint">3768</value>
- <value key="RunConfiguration.UseCppDebugger" type="bool">true</value>
- <value key="RunConfiguration.UseQmlDebugger" type="bool">false</value>
- </valuemap>
- <value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
- </valuemap>
- </data>
- <data>
- <variable>ProjectExplorer.Project.TargetCount</variable>
- <value type="int">1</value>
- </data>
- <data>
- <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
- <value type="QString">{84cffe42-92b8-4375-bbf8-8eb13854cf70}</value>
- </data>
- <data>
- <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
- <value type="int">9</value>
- </data>
-</qtcreator>
View
45 TD04/TD4.cbp
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<CodeBlocks_project_file>
+ <FileVersion major="1" minor="6" />
+ <Project>
+ <Option title="TD4" />
+ <Option pch_mode="2" />
+ <Option compiler="gcc" />
+ <Build>
+ <Target title="Debug">
+ <Option output="bin\Debug\TD4" prefix_auto="1" extension_auto="1" />
+ <Option object_output="obj\Debug\" />
+ <Option type="1" />
+ <Option compiler="gcc" />
+ <Compiler>
+ <Add option="-g" />
+ </Compiler>
+ </Target>
+ <Target title="Release">
+ <Option output="bin\Release\TD4" prefix_auto="1" extension_auto="1" />
+ <Option object_output="obj\Release\" />
+ <Option type="1" />
+ <Option compiler="gcc" />
+ <Compiler>
+ <Add option="-O2" />
+ </Compiler>
+ <Linker>
+ <Add option="-s" />
+ </Linker>
+ </Target>
+ </Build>
+ <Compiler>
+ <Add option="-Wall" />
+ <Add option="-fexceptions" />
+ </Compiler>
+ <Unit filename="evenement.cpp" />
+ <Unit filename="evenement.h" />
+ <Unit filename="main.cpp" />
+ <Unit filename="time.cpp" />
+ <Unit filename="time.h" />
+ <Extensions>
+ <code_completion />
+ <debugger />
+ </Extensions>
+ </Project>
+</CodeBlocks_project_file>
View
23 TD04/TD4.depend
@@ -0,0 +1,23 @@
+# depslib dependency file v1.0
+1334324524 source:c:\users\thomas\desktop\td4\time.cpp
+ <iomanip>
+ "time.h"
+ <ctime>
+
+1334324553 c:\users\thomas\desktop\td4\time.h
+ <iostream>
+ <iomanip>
+
+1334330350 source:c:\users\thomas\desktop\td4\main.cpp
+ <iostream>
+ "evenement.h"
+
+1334330793 source:c:\users\thomas\desktop\td4\evenement.cpp
+ "evenement.h"
+ <new>
+
+1334330871 c:\users\thomas\desktop\td4\evenement.h
+ <string>
+ <iostream>
+ "time.h"
+
View
19 TD04/TD4.layout
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<CodeBlocks_layout_file>
+ <ActiveTarget name="Debug" />
+ <File name="evenement.cpp" open="1" top="0" tabpos="5">
+ <Cursor position="1037" topLine="26" />
+ </File>
+ <File name="evenement.h" open="1" top="1" tabpos="4">
+ <Cursor position="1639" topLine="47" />
+ </File>
+ <File name="main.cpp" open="1" top="0" tabpos="1">
+ <Cursor position="461" topLine="9" />
+ </File>
+ <File name="time.cpp" open="1" top="0" tabpos="2">
+ <Cursor position="0" topLine="0" />
+ </File>
+ <File name="time.h" open="1" top="0" tabpos="3">
+ <Cursor position="0" topLine="0" />
+ </File>
+</CodeBlocks_layout_file>
View
58 TD04/evenement.cpp
@@ -0,0 +1,58 @@
+#include "evenement.h"
+#include <new>
+
+
+ostream& operator<<(ostream& os, const Ev_1j& ev) {
+ ev.afficher(os);
+ return os;
+}
+
+
+
+
+ostream& operator<<(ostream& os, const Agenda& a) {
+ a.afficher(os);
+ return os;
+}
+
+
+Agenda::Agenda(int i) : _nb_events(0), _taille_max(i) {
+ _events = new Ev_1j*[i];
+}
+
+Agenda::~Agenda() {
+ for (int i=0; i < _nb_events; ++i) {
+ delete _events[i];
+ }
+ delete[] _events;
+}
+
+Agenda& Agenda::operator<<(const Ev_1j& ev) {
+ if (_nb_events >= _taille_max) {
+ Ev_1j **temp = new Ev_1j*[_taille_max];
+ for (int i=0; i<_taille_max; ++i) {
+ temp[i] = _events[i];
+ }
+ delete[] _events;
+ int new_taille_max = _taille_max*2;
+ _events = new Ev_1j*[new_taille_max];
+ for (int i=0; i<_taille_max; ++i) {
+ _events[i] = temp[i];
+ }
+ delete[] temp;
+ _nb_events = _taille_max;
+ _taille_max = new_taille_max;
+ }
+ _events[_nb_events] = ev.clone();
+ ++_nb_events;
+ return *this;
+}
+
+void Agenda::afficher(ostream& f) const {
+ f << "******** agenda ********" << endl;
+ for (int i=0; i<_nb_events; ++i) {
+ f << "Event " << i << " : " << endl;
+ f << (*_events[i]) << endl;
+ }
+}
+
View
115 TD04/evenement.h
@@ -0,0 +1,115 @@
+#ifndef EVENEMENT_H_INCLUDED
+#define EVENEMENT_H_INCLUDED
+
+#include <string>
+#include <iostream>
+
+using namespace std;
+
+#include "time.h"
+
+using namespace TIME;
+
+class Ev_1j
+{
+ protected:
+ Date _date;
+ string _objet;
+
+ public:
+ Ev_1j(int j, int m, int a, const string& s) : _date(j,m,a), _objet(s) {};
+ Ev_1j(const Ev_1j& ev) : _date(ev._date), _objet(ev._objet) {};
+ virtual ~Ev_1j() {};
+ virtual Ev_1j * clone() const { return new Ev_1j(*this); };
+ const string& get_description() const { return _objet; }
+ const Date& get_date() const { return _date; }
+ virtual void afficher(ostream& f= cout) const {
+ f<<"******** evt ********"<<endl;
+ f<<"Date="<<_date<<" Objet="<<_objet<<endl;
+ }
+};
+
+class Ev_1j_dur : public Ev_1j
+{
+ protected:
+ Horaire _debut;
+ Duree _duree;
+
+ public:
+ Ev_1j_dur(int j, int m, int a, const string& s,
+ int hh, int hm, int dh, int dm) : Ev_1j(j, m, a, s), _debut(hh,hm), _duree(dh, dm) {};
+ Ev_1j_dur(const Ev_1j_dur& ev) : Ev_1j(ev), _debut(ev._debut), _duree(ev._duree) {};
+ Ev_1j_dur * clone() const { return new Ev_1j_dur(*this); };
+ const Horaire& get_debut() const { return _debut; };
+ const Duree& get_duree() const { return _duree; };
+
+ void afficher(ostream& f= cout) const {
+ Ev_1j::afficher(f);
+ f<<"Debut="<<_debut<<" Durée="<<_duree<<endl;
+ }
+};
+
+
+class Rdv : public Ev_1j_dur
+{
+ protected:
+ string _lieu;
+ string _personne;
+
+ public:
+ Rdv(int j, int m, int a, const string& s,
+ int hh, int hm, int dh, int dm,
+ const string& lieu, const string& personne) :
+ Ev_1j_dur(j,m,a,s,hh,hm,dh,dm),
+ _lieu(lieu), _personne(personne) {};
+ Rdv(const Rdv& rdv) : Ev_1j_dur(rdv), _lieu(rdv._lieu), _personne(_personne) {};
+ Rdv * clone() const { return new Rdv(*this); };
+
+ const string& get_lieu() const { return _lieu; };
+ const string& get_personne() const { return _personne; };
+
+ void afficher(ostream& f=cout) const {
+ Ev_1j_dur::afficher(f);
+ f << "Lieu=" << _lieu << " Personne=" << _personne << endl;
+ }
+};
+
+ostream& operator<<(ostream& os, const Ev_1j& ev);
+
+
+class Agenda_iterator
+{
+ private:
+ Ev_1j ** _ptr;
+ public:
+ Agenda_iterator() : _ptr(0) {};
+ Agenda_iterator(Ev_1j** ptr) : _ptr(ptr) {};
+
+ bool operator!=(const Agenda_iterator& it) { return it._ptr != _ptr; };
+ Agenda_iterator& next() {++_ptr; return *this;};
+ Ev_1j& value() {return **_ptr;};
+};
+
+class Agenda
+{
+ protected:
+ Ev_1j** _events;
+ int _nb_events;
+ int _taille_max;
+
+ public:
+ friend class Agenda_iterator;
+ typedef Agenda_iterator iterator;
+ Agenda(int i = 10);
+ virtual ~Agenda();
+ Agenda& operator<<(const Ev_1j& ev);
+ virtual void afficher(ostream& f=cout) const;
+ Agenda_iterator first() { return Agenda_iterator(_events); }
+ Agenda_iterator end() { return Agenda_iterator(_events+_nb_events); };
+};
+
+
+
+ostream& operator<<(ostream& os, const Agenda& a);
+
+#endif // EVENEMENT_H_INCLUDED
View
37 TD04/main.cpp
@@ -1,8 +1,29 @@
-#include <QtCore/QCoreApplication>
-
-int main(int argc, char *argv[])
-{
- QCoreApplication a(argc, argv);
-
- return a.exec();
-}
+#include <iostream>
+using namespace std;
+
+#include "evenement.h"
+
+int main()
+{
+ Ev_1j ev_1j(1, 3, 2010, "un ev de 1j");
+ cout << ev_1j << endl;
+
+ Ev_1j_dur ev_1j_dur(4, 12, 2020, "un ev de 1j avec durée", 5,42, 1,30);
+ cout << ev_1j_dur << endl;
+
+ Rdv rdv(10, 11, 2013, "un rdv", 10,42, 1,0, "un garage", "du beau monde");
+ cout << rdv << endl;
+
+ Agenda agenda(1);
+
+ agenda << ev_1j << ev_1j_dur << rdv;
+ cout << agenda << endl;
+
+ cout << "iterator" << endl;
+ Agenda::iterator end = agenda.end();
+ for (Agenda::iterator it = agenda.first(); it!=end; it.next()) {
+ cout << it.value() << endl;
+ }
+
+ return 0;
+}
View
124 TD04/time.cpp
@@ -0,0 +1,124 @@
+#include <iomanip>
+#include "time.h"
+#include <ctime>
+
+std::ostream& operator<<(std::ostream& f, const TIME::Date& x){ x.Afficher(f); return f;}
+std::ostream& operator<<(std::ostream& f, const TIME::Duree & d){ d.Afficher(f); return f; }
+std::ostream& operator<<(std::ostream& f, const TIME::Horaire & h){ h.Afficher(f); return f; }
+std::ostream& operator<<(std::ostream& f, const TIME::Periode & p){ p.Afficher(f); return f; }
+
+
+void TIME::Date::SetDate(unsigned short int j, unsigned short int m, unsigned int a){
+ // initialisation de la date, renvoie vrai si la date est valide
+ if (a>=0&&a<=3000) annee=a; else throw TimeException("erreur: annee invalide");
+ if (m>=1&&m<=12) mois=m; else throw TimeException("erreur: mois invalide");
+ switch(m){
+ case 1: case 3: case 5: case 7: case 8: case 10: case 12: if (j>=1 && j<=31) jour=j; else throw TimeException("erreur: jour invalide"); break;
+ case 4: case 6: case 9: case 11: if (j>=1 && j<=30) jour=j; else throw TimeException("erreur: jour invalide"); break;
+ case 2: if (j>=1 && (j<=29 || (j==30 && a%4==0))) jour=j; else throw TimeException("erreur: jour invalide"); break;
+ }
+}
+
+void TIME::Date::SetDateAujourdhui(){
+ // initialisation de la date avec la date d'aujourd'hui
+ time_t rawtime;
+ struct tm * timeinfo;
+ time ( &rawtime );
+ timeinfo = localtime ( &rawtime );
+ jour=timeinfo->tm_mday;
+ mois=timeinfo->tm_mon+1;
+ annee=timeinfo->tm_year+1900;
+}
+
+void TIME::Date::Afficher(std::ostream& f) const{
+ // affiche le date sous le format JJ/MM/AAAA
+ f<<std::setfill('0')<<std::setw(2)<<jour<<"/"<<std::setw(2)<<mois<<"/"<<annee;
+}
+
+bool TIME::Date::operator==(const TIME::Date& d) const{
+ if (annee<d.annee) return false;
+ if (annee>d.annee) return false;
+ if (mois<d.mois) return false;
+ if (mois>d.mois) return false;
+ if (jour<d.jour) return false;
+ if (jour>d.jour) return false;
+ return true;
+}
+
+bool TIME::Date::operator<(const TIME::Date& d) const{
+ if (annee<d.annee) return true;
+ if (annee>d.annee) return false;
+ if (mois<d.mois) return true;
+ if (mois>d.mois) return false;
+ if (jour<d.jour) return true;
+ if (jour>d.jour) return false;
+ return false;
+}
+
+int TIME::Date::operator-(const TIME::Date& d) const{
+ int n=(annee-d.annee)*365+(annee-d.annee)/4;
+ n+=int((mois-d.mois)*30.5);
+ n+=jour-d.jour;
+ return n;
+}
+
+TIME::Date TIME::Date::Demain() const{
+ Date d=*this;
+ d.jour+=1;
+ switch(d.mois){
+ case 1: case 3: case 5: case 7: case 8: case 10: case 12: if (d.jour==30) { d.jour=1; d.mois++; } break;
+ case 4: case 6: case 9: case 11: if (d.jour==31) { d.jour=1; d.mois++; } break;
+ case 2: if (d.jour==29 && d.annee%4>0) { d.jour=1; d.mois++; } if (d.jour==30) { d.jour=1; d.mois++; } break;
+ }
+ if (d.mois==13){ d.annee++; d.mois=1; }
+ return d;
+}
+
+TIME::Date TIME::Date::operator+(unsigned int nb_jours) const{
+ Date d=*this;
+ while(nb_jours>0) { d=d.Demain(); nb_jours--; }
+ return d;
+}
+
+bool TIME::Horaire::operator<(const Horaire& h) const{
+ if (heure<h.heure) return true;
+ if (heure>h.heure) return false;
+ if (minute<h.minute) return true;
+ if (minute>h.minute) return false;
+ return true;
+}
+
+TIME::Periode::Periode(unsigned int j, unsigned int m, unsigned int a):
+ nb_jours(j), nb_mois(m), nb_annees(a) {
+ if (j>364) throw TimeException("erreur: initialisation periode invalide");
+ if (m>11) throw TimeException("erreur: initialisation periode invalide");
+}
+
+
+std::ostream& operator<<(std::ostream& f, const TIME::Intervalle& x){ x.Afficher(f); return f;}
+
+
+TIME::Intervalle::Intervalle(const Date & d, const Date & f):debut(d),fin(f){
+ if (fin<debut) throw TimeException("Erreur dans la creation d'un intervalle: fin<debut");
+}
+
+bool TIME::Intervalle::operator&&(const Intervalle & v) const {
+ if (debut<v.debut){
+ if (fin<v.debut) return false; else return true;
+ }
+ if (v.fin<fin){
+ if (v.fin<debut) return false; else return true;
+ }
+ return true;
+}
+
+TIME::Intervalle TIME::Intervalle::operator+(const Intervalle & i) const {
+ Date d=fin.Demain();
+ if (d==i.debut){
+ return Intervalle(debut,i.fin);
+ }else throw TimeException("Ne peut pas faire l'union de 2 intervalles (ils ne se touchent pas...");
+}
+
+void TIME::Intervalle::Afficher(std::ostream& f) const {
+ f<<"["<<debut<<" ; "<<fin<<"]";
+}
View
150 TD04/time.h
@@ -0,0 +1,150 @@
+#if !defined(CTIME)
+#define CTIME
+
+#include<iostream>
+#include<iomanip>
+
+namespace TIME {
+ /*! \class TimeException
+ \brief Classe permettant de g�rer les exceptions des classes du namespace TIME
+ */
+ class TimeException{
+ public:
+ //! Constructeur � partir d'une string
+ TimeException(const std::string& m):info(m){}
+ const std::string& GetInfo() const { return info; } //<! Retourne l'information stock�e dans la classe
+ private:
+ std::string info;
+ };
+
+ /*! \class Date
+ \brief Classe permettant de manipuler des dates standards
+ L'utilisation de cette classe n�cessite des dates valides au sens commun du terme.
+ D�clenchement d'exception dans le cas contraire
+ */
+ class Date {
+ public:
+ //! Constructeur � partir d'un jour, mois, ann�e
+ /*! \param j jour avec 1<=j<=31
+ \param m mois avec 1<=m<=12
+ \param a ann�e avec a>=0
+ */
+ Date(short j=1, short m=1, unsigned int a=0):jour(1),mois(1),annee(0){ SetDate(j,m,a); }
+ // m�thodes
+ unsigned short int GetJour() const { return jour; } //<! Retourne le jour de la date
+ unsigned short int GetMois() const { return mois; } //<! Retourne le mois de la date
+ unsigned int GetAnnee() const { return annee; } //<! Retourne l'ann�e de la date
+ void SetDate(unsigned short int j, unsigned short int m, unsigned int a); //!< initialisation de la date
+ void SetDateAujourdhui(); //!< initialisation de la date avec la date d'aujourd'hui
+ void Afficher(std::ostream& f=std::cout) const; //!< affiche le date sous le format JJ/MM/AAAA
+ bool operator==(const Date& d) const; //<! d1==d2 retourne vrai si les deux dates sont �gales
+ bool operator<(const Date& d) const; //<! Compare deux dates dans le temps : d1<d2 retourne true si d1 est avant d2
+ int operator-(const Date& d) const; //<! Retourne le nombre de jours s�parant les deux dates
+ Date Demain() const; //<! Retourne la date du lendemain
+ Date operator+(unsigned int nb) const; //<!Retourne la date de dans nb jours
+ private:
+ // attributs
+ unsigned short int jour; // jour entre 1 et 31
+ unsigned short int mois; // mois entre 1 et 12
+ unsigned int annee;
+ };
+
+ /*! \class Duree
+ \brief Classe permettant de manipuler des durees
+ L'utilisation de cette classe n�cessite des dates valides au sens commun du terme.
+ D�clenchement d'exception dans le cas contraire
+ */
+ class Duree{
+ public:
+ //! Constructeur � partir de heure et minute
+ /*! \param h heure avec h>=0
+ \param m minute avec 0<=m<=59
+ */
+ Duree(unsigned int h, unsigned int m):nb_minutes(h*60+m) {if (m>59) throw TimeException("erreur: initialisation duree invalide");}
+ //! Constructeur � partir de minute
+ /*! \param m minute avec m>=0
+ */
+ Duree(unsigned int m):nb_minutes(m) {}
+ void SetDuree(unsigned int heures, unsigned int minutes) { if (minutes>59) throw TimeException("erreur: initialisation duree invalide"); nb_minutes=heures*60+minutes; }
+ unsigned int GetDureeEnMinutes() const { return nb_minutes; } //<!Retourne la duree en minutes
+ double GetDureeEnHeures() const { return double(nb_minutes)/60; } //<!Retourne la duree en heures
+ void Afficher(std::ostream& f=std::cout) const { f<<nb_minutes/60<<"H"<<std::setw(2)<<nb_minutes%60; } //<!Affiche la duree sous le format hhHmm
+ private:
+ unsigned int nb_minutes;
+ };
+
+ /*! \class Horaire
+ \brief Classe permettant de manipuler des horaires
+ L'utilisation de cette classe n�cessite des dates valides au sens commun du terme.
+ D�clenchement d'exception dans le cas contraire
+ */
+ class Horaire{
+ public:
+ //! Constructeur � partir de heure et minute
+ /*! \param h heure avec 0<=h<=23
+ \param m minute avec 0<=m<=59
+ */
+ Horaire(unsigned short int h, unsigned short int m):heure(h),minute(m) {if (h>23||m>59) throw TimeException("erreur: initialisation horaire invalide");}
+ void SetHoraire(unsigned short int h, unsigned short int m) { if (h>23||m>59) throw TimeException("erreur: initialisation horaire invalide"); heure=h; minute=m; }
+ void Afficher(std::ostream& f=std::cout) const { f<<heure<<"H"<<minute; } //<!Affiche l'horaire sous le format hhHmm
+ unsigned short int GetHeure() const { return heure; } //<!Retourne l'heure de l'horaire
+ unsigned short int GetMinute() const { return minute; } //<!Retourne les minutes de l'horaire
+ bool operator<(const Horaire& h) const; //<! h1<h2 retourne true si h1 est avant h2 dans le temps
+ private:
+ unsigned short int heure;
+ unsigned short int minute;
+ };
+
+ /*! \class Periode
+ \brief Classe permettant de manipuler des periodes exprim�es en jours/mois/ann�es
+ L'utilisation de cette classe n�cessite des dates valides au sens commun du terme.
+ D�clenchement d'exception dans le cas contraire
+ */
+ class Periode{
+ public :
+ //! Constructeur � partir de jour/mois/ann�e
+ /*! \param j nombre de jours avec 0<=j<=364
+ \param m nombre de mois avec 0<=m<=11
+ \param a nombre d'ann�es
+ */
+ Periode(unsigned int j, unsigned int m, unsigned int a);
+ void Afficher(std::ostream& f=std::cout) const { f<<"{"<<nb_jours<<" jours, "<<nb_mois<<" mois, "<<nb_annees<<" ans}"; }
+ private:
+ unsigned int nb_jours;
+ unsigned int nb_mois;
+ unsigned int nb_annees;
+ };
+
+ /*! \class Intervalle
+ \brief Classe permettant de manipuler des intervalles de dates
+ L'utilisation de cette classe n�cessite des dates valides au sens commun du terme.
+ D�clenchement d'exception dans le cas contraire
+ */
+ class Intervalle{
+ public:
+ //! Constructeur � partir de deux dates
+ /*! \param d date de d�but de l'intervalle
+ \param f date de fin de l'intervalle. On doit avoir d<=f
+ */
+ Intervalle(const Date & d, const Date & f);
+ void Afficher(std::ostream& f=std::cout) const; //<! Affiche l'intervalle de dates
+ Date GetDebut() const { return debut; } //<! Retourne la date de d�but de l'intervalle
+ Date GetFin() const { return fin; } //<! Retourne la date de fin de l'intervalle
+ int GetDuree() const { return fin-debut; } //<! Retourne le nombre de jours s'�coulant entre le d�but et la fin de l'intervalle
+ bool operator&&(const Intervalle & v) const; //<! I1&&I2 Retourne vrai si il y a intersection entre I1 et I2
+ Intervalle operator + (const Intervalle & i) const; //<! I1+I2 Retourne un intervalle union des 2 intervalles I1 et I2 qui se touchent, ie I2.debut est le jour du lendemain de I1.fin
+ private:
+ Date debut;
+ Date fin;
+ };
+
+}
+
+std::ostream& operator<<(std::ostream&, const TIME::Date&);
+std::ostream& operator<<(std::ostream& f, const TIME::Duree & d);
+std::ostream& operator<<(std::ostream& f, const TIME::Horaire & h);
+std::ostream& operator<<(std::ostream& f, const TIME::Periode & p);
+std::ostream& operator<<(std::ostream& f, const TIME::Intervalle & p);
+
+#endif
+
View
28 TP2/src/operation.h
@@ -0,0 +1,28 @@
+#ifndef OPERATION_H
+#define OPERATION_H
+
+enum T_OPERATION {
+ RETRAIT,
+ DEPOSE,
+ TRANSFERT,
+};
+
+class Operation
+{
+ public:
+ Operation(
+
+ private:
+ time_t date;
+ T_OPERATION type;
+ string
+
+
+};
+
+
+
+
+#endif
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.