Răsfoiți Sursa

init with subjects

bchanot 5 luni în urmă
părinte
comite
d81a6b9925

+ 59 - 0
Module_00/19920104_091532.log

@@ -0,0 +1,59 @@
+[19920104_091532] index:0;amount:42;created
+[19920104_091532] index:1;amount:54;created
+[19920104_091532] index:2;amount:957;created
+[19920104_091532] index:3;amount:432;created
+[19920104_091532] index:4;amount:1234;created
+[19920104_091532] index:5;amount:0;created
+[19920104_091532] index:6;amount:754;created
+[19920104_091532] index:7;amount:16576;created
+[19920104_091532] accounts:8;total:20049;deposits:0;withdrawals:0
+[19920104_091532] index:0;amount:42;deposits:0;withdrawals:0
+[19920104_091532] index:1;amount:54;deposits:0;withdrawals:0
+[19920104_091532] index:2;amount:957;deposits:0;withdrawals:0
+[19920104_091532] index:3;amount:432;deposits:0;withdrawals:0
+[19920104_091532] index:4;amount:1234;deposits:0;withdrawals:0
+[19920104_091532] index:5;amount:0;deposits:0;withdrawals:0
+[19920104_091532] index:6;amount:754;deposits:0;withdrawals:0
+[19920104_091532] index:7;amount:16576;deposits:0;withdrawals:0
+[19920104_091532] index:0;p_amount:42;deposit:5;amount:47;nb_deposits:1
+[19920104_091532] index:1;p_amount:54;deposit:765;amount:819;nb_deposits:1
+[19920104_091532] index:2;p_amount:957;deposit:564;amount:1521;nb_deposits:1
+[19920104_091532] index:3;p_amount:432;deposit:2;amount:434;nb_deposits:1
+[19920104_091532] index:4;p_amount:1234;deposit:87;amount:1321;nb_deposits:1
+[19920104_091532] index:5;p_amount:0;deposit:23;amount:23;nb_deposits:1
+[19920104_091532] index:6;p_amount:754;deposit:9;amount:763;nb_deposits:1
+[19920104_091532] index:7;p_amount:16576;deposit:20;amount:16596;nb_deposits:1
+[19920104_091532] accounts:8;total:21524;deposits:8;withdrawals:0
+[19920104_091532] index:0;amount:47;deposits:1;withdrawals:0
+[19920104_091532] index:1;amount:819;deposits:1;withdrawals:0
+[19920104_091532] index:2;amount:1521;deposits:1;withdrawals:0
+[19920104_091532] index:3;amount:434;deposits:1;withdrawals:0
+[19920104_091532] index:4;amount:1321;deposits:1;withdrawals:0
+[19920104_091532] index:5;amount:23;deposits:1;withdrawals:0
+[19920104_091532] index:6;amount:763;deposits:1;withdrawals:0
+[19920104_091532] index:7;amount:16596;deposits:1;withdrawals:0
+[19920104_091532] index:0;p_amount:47;withdrawal:refused
+[19920104_091532] index:1;p_amount:819;withdrawal:34;amount:785;nb_withdrawals:1
+[19920104_091532] index:2;p_amount:1521;withdrawal:657;amount:864;nb_withdrawals:1
+[19920104_091532] index:3;p_amount:434;withdrawal:4;amount:430;nb_withdrawals:1
+[19920104_091532] index:4;p_amount:1321;withdrawal:76;amount:1245;nb_withdrawals:1
+[19920104_091532] index:5;p_amount:23;withdrawal:refused
+[19920104_091532] index:6;p_amount:763;withdrawal:657;amount:106;nb_withdrawals:1
+[19920104_091532] index:7;p_amount:16596;withdrawal:7654;amount:8942;nb_withdrawals:1
+[19920104_091532] accounts:8;total:12442;deposits:8;withdrawals:6
+[19920104_091532] index:0;amount:47;deposits:1;withdrawals:0
+[19920104_091532] index:1;amount:785;deposits:1;withdrawals:1
+[19920104_091532] index:2;amount:864;deposits:1;withdrawals:1
+[19920104_091532] index:3;amount:430;deposits:1;withdrawals:1
+[19920104_091532] index:4;amount:1245;deposits:1;withdrawals:1
+[19920104_091532] index:5;amount:23;deposits:1;withdrawals:0
+[19920104_091532] index:6;amount:106;deposits:1;withdrawals:1
+[19920104_091532] index:7;amount:8942;deposits:1;withdrawals:1
+[19920104_091532] index:0;amount:47;closed
+[19920104_091532] index:1;amount:785;closed
+[19920104_091532] index:2;amount:864;closed
+[19920104_091532] index:3;amount:430;closed
+[19920104_091532] index:4;amount:1245;closed
+[19920104_091532] index:5;amount:23;closed
+[19920104_091532] index:6;amount:106;closed
+[19920104_091532] index:7;amount:8942;closed

+ 69 - 0
Module_00/Account.hpp

@@ -0,0 +1,69 @@
+// ************************************************************************** //
+//                                                                            //
+//                Account.hpp for GlobalBanksters United                //
+//                Created on  : Thu Nov 20 19:43:15 1989                      //
+//                Last update : Wed Jan 04 14:54:06 1992                      //
+//                Made by : Brad "Buddy" McLane <bm@gbu.com>                  //
+//                                                                            //
+// ************************************************************************** //
+
+
+#pragma once
+#ifndef __ACCOUNT_H__
+#define __ACCOUNT_H__
+
+// ************************************************************************** //
+//                               Account Class                                //
+// ************************************************************************** //
+
+class Account {
+
+
+public:
+
+	typedef Account		t;
+
+	static int	getNbAccounts( void );
+	static int	getTotalAmount( void );
+	static int	getNbDeposits( void );
+	static int	getNbWithdrawals( void );
+	static void	displayAccountsInfos( void );
+
+	Account( int initial_deposit );
+	~Account( void );
+
+	void	makeDeposit( int deposit );
+	bool	makeWithdrawal( int withdrawal );
+	int		checkAmount( void ) const;
+	void	displayStatus( void ) const;
+
+
+private:
+
+	static int	_nbAccounts;
+	static int	_totalAmount;
+	static int	_totalNbDeposits;
+	static int	_totalNbWithdrawals;
+
+	static void	_displayTimestamp( void );
+
+	int				_accountIndex;
+	int				_amount;
+	int				_nbDeposits;
+	int				_nbWithdrawals;
+
+	Account( void );
+
+};
+
+
+
+// ************************************************************************** //
+// vim: set ts=4 sw=4 tw=80 noexpandtab:                                      //
+// -*- indent-tabs-mode:t;                                                   -*-
+// -*- mode: c++-mode;                                                       -*-
+// -*- fill-column: 75; comment-column: 75;                                  -*-
+// ************************************************************************** //
+
+
+#endif /* __ACCOUNT_H__ */

+ 312 - 0
Module_00/fr.subject.pdf

@@ -0,0 +1,312 @@
+              C++ - Module 00
+
+  Namespaces, classes, fonctions membres, stdio
+                         streams,
+
+listes d’initialisation, static, const, et autres bases
+
+                                              Résumé:
+        Ce document contient les exercices du Module 00 des C++ modules.
+
+                                             Version: 9
+Table des matières
+
+I   Introduction                         2
+
+II  Consignes générales                  3
+
+III Exercice 00 : Mégaphone              5
+
+IV Exercice 01 : My Awesome PhoneBook    6
+
+V   Exercice 02 : L’emploi de vos rêves  8
+
+VI Submission and peer-evaluation        10
+
+                             1
+Chapitre I
+
+Introduction
+
+    C++ is a general-purpose programming language created by Bjarne Stroustrup as an
+extension of the C programming language, or "C with Classes" (source : Wikipedia).
+
+    C++ est un langage de programmation compilé permettant la programmation sous
+de multiples paradigmes, dont la programmation procédurale, la programmation orientée
+objet et la programmation générique. Ses bonnes performances, et sa compatibilité avec le
+C en font un des langages de programmation les plus utilisés dans les applications où la
+performance est critique (source : Wikipedia).
+
+    Ces modules ont pour but de vous introduire à la Programmation Orientée Objet.
+Plusieurs langages sont recommandés pour l’apprentissage de l’OOP. Du fait qu’il soit
+dérivé de votre bon vieil ami le C, nous avons choisi le langage C++. Toutefois, étant un
+langage complexe et afin de ne pas vous compliquer la tâche, vous vous conformerez au
+standard C++98.
+
+    Nous avons conscience que le C++ moderne est différent sur bien des aspects. Si vous
+souhaitez pousser votre maîtrise du C++, c’est à vous de creuser après le tronc commun
+de 42 !
+
+    Vous découvrirez de nouveaux concepts au fur et à mesure. Leur difficulté ira crois-
+sante.
+
+                                                        2
+Chapitre II
+
+Consignes générales
+
+    Compilation
+
+     • Compilez votre code avec c++ et les flags -Wall -Wextra -Werror
+     • Votre code doit compiler si vous ajoutez le flag -std=c++98
+
+    Format et conventions de nommage
+
+     • Les dossiers des exercices seront nommés ainsi : ex00, ex01, ... , exn
+     • Nommez vos fichiers, vos classes, vos fonctions, vos fonctions membres et vos at-
+
+        tributs comme spécifié dans les consignes.
+     • Rédigez vos noms de classe au format UpperCamelCase. Les fichiers contenant
+
+        le code d’une classe porteront le nom de cette dernière. Par exemple :
+        NomDeClasse.hpp/NomDeClasse.h, NomDeClasse.cpp, ou NomDeClasse.tpp.
+        Ainsi, si un fichier d’en-tête contient la définition d’une classe "BrickWall", son
+        nom sera BrickWall.hpp.
+     • Sauf si spécifié autrement, tous les messages doivent être terminés par un retour
+        à la ligne et être affichés sur la sortie standard.
+     • Ciao Norminette ! Aucune norme n’est imposée durant les modules C++. Vous
+        pouvez suivre le style de votre choix. Mais ayez à l’esprit qu’un code que vos pairs
+        ne peuvent comprendre est un code que vos pairs ne peuvent évaluer. Faites donc
+        de votre mieux pour produire un code propre et lisible.
+
+    Ce qui est autorisé et ce qui ne l’est pas
+
+    Le langage C, c’est fini pour l’instant. Voici l’heure de se mettre au C++ ! Par consé-
+quent :
+
+     • Vous pouvez avoir recours à quasi l’ensemble de la bibliothèque standard. Donc
+        plutôt que de rester en terrain connu, essayez d’utiliser le plus possible les versions
+        C++ des fonctions C dont vous avec l’habitude.
+
+     • Cependant, vous ne pouvez avoir recours à aucune autre bibliothèque externe.
+        Ce qui signifie que C++11 (et dérivés) et l’ensemble Boost sont interdits. Aussi,
+        certaines fonctions demeurent interdites. Utiliser les fonctions suivantes résultera
+
+                                                        3
+C++ - Module 00  Namespaces, classes, fonctions membres, stdio streams,
+                       listes d’initialisation, static, const, et autres bases
+
+  en la note de 0 : *printf(), *alloc() et free().
+
+• Sauf si explicitement indiqué autrement, les mots-clés using namespace <ns_name>
+  et friend sont interdits. Leur usage résultera en la note de -42.
+
+• Vous n’avez le droit à la STL que dans les Modules 08 et 09. D’ici là,
+  l’usage des Containers (vector/list/map/etc.) et des Algorithmes (tout ce qui
+  requiert d’inclure <algorithm>) est interdit. Dans le cas contraire, vous obtiendrez
+  la note de -42.
+
+Quelques obligations côté conception
+
+• Les fuites de mémoires existent aussi en C++. Quand vous allouez de la mémoire
+  (en utilisant le mot-clé new), vous ne devez pas avoir de memory leaks.
+
+• Du Module 02 au Module 09, vos classes devront se conformer à la forme cano-
+  nique, dite de Coplien, sauf si explicitement spécifié autrement.
+
+• Une fonction implémentée dans un fichier d’en-tête (hormis dans le cas de fonction
+  template) équivaudra à la note de 0.
+
+• Vous devez pouvoir utiliser vos fichiers d’en-tête séparément les uns des autres.
+  C’est pourquoi ils devront inclure toutes les dépendances qui leur seront néces-
+  saires. Cependant, vous devez éviter le problème de la double inclusion en les
+  protégeant avec des include guards. Dans le cas contraire, votre note sera de 0.
+
+Read me
+
+• Si vous en avez le besoin, vous pouvez rendre des fichiers supplémentaires (par
+  exemple pour séparer votre code en plus de fichiers). Vu que votre travail ne sera
+  pas évalué par un programme, faites ce qui vous semble le mieux du moment que
+  vous rendez les fichiers obligatoires.
+
+• Les consignes d’un exercice peuvent avoir l’air simple mais les exemples contiennent
+  parfois des indications supplémentaires qui ne sont pas explicitement demandées.
+
+• Lisez entièrement chaque module avant de commencer ! Vraiment.
+
+• Par Odin, par Thor ! Utilisez votre cervelle ! ! !
+
+         Vous aurez à implémenter un bon nombre de classes, ce qui pourrait
+         s’avérer ardu... ou pas ! Il y a peut-être moyen de vous simplifier
+         la vie grâce à votre éditeur de texte préféré.
+
+         Vous êtes assez libre quant à la manière de résoudre les exercices.
+         Toutefois, respectez les consignes et ne vous en tenez pas au strict
+         minimum, vous pourriez passer à côté de notions intéressantes.
+         N’hésitez pas à lire un peu de théorie.
+
+                 4
+Chapitre III
+Exercice 00 : Mégaphone
+
+                                                   Exercice : 00
+                                                        Mégaphone
+
+    Dossier de rendu : ex00/
+    Fichiers à rendre : Makefile, megaphone.cpp
+    Fonctions interdites : Aucune
+
+    Afin de s’assurer que tout le monde est bien réveillé, écrivez un programme qui se
+comporte comme suit :
+
+  $>./megaphone "shhhhh... I think the students are asleep..."
+  SHHHHH... I THINK THE STUDENTS ARE ASLEEP...
+  $>./megaphone Damnit " ! " "Sorry students, I thought this thing was off."
+  DAMNIT ! SORRY STUDENTS, I THOUGHT THIS THING WAS OFF.
+  $>./megaphone
+  * LOUD AND UNBEARABLE FEEDBACK NOISE *
+  $>
+
+                     Faites les exercices d’une "façon" C++.
+
+                                                        5
+Chapitre IV
+
+Exercice 01 : My Awesome
+PhoneBook
+
+                                                   Exercice : 01
+                                              My Awesome PhoneBook
+    Dossier de rendu : ex01/
+    Fichiers à rendre : Makefile, *.cpp, *.{h, hpp}
+    Fonctions interdites : Aucune
+
+    Bienvenue dans les années 80 et leur incroyable technologie ! Concevez un programme
+qui se comporte comme un répertoire pas si incroyable que ça.
+
+    Vous devez implémenter deux classes :
+
+     • PhoneBook
+          ◦ Représente le répertoire.
+          ◦ Contient un tableau de contacts.
+          ◦ Peut enregistrer 8 contacts maximum. Si l’utilisateur tente d’ajouter un 9ème
+             contact, remplacez le plus ancien par celui-ci.
+          ◦ Notez que l’allocation dynamique est interdite.
+
+     • Contact
+          ◦ Représente un contact dans le répertoire.
+
+    Dans votre code, l’objet répertoire doit être une instance de la classe PhoneBook.
+Même chose pour les objets contacts, qui doivent être chacun une instance de la classe
+Contact. Vous êtes libre de concevoir vos classes comme vous le sentez. Par contre, ayez
+en tête que ce qui est toujours utilisé dans une classe est privé, et que ce qui peut l’être
+en dehors est public.
+
+                     N’oubliez pas de regarder les vidéos de l’intranet.
+
+                                                        6
+C++ - Module 00  Namespaces, classes, fonctions membres, stdio streams,
+                       listes d’initialisation, static, const, et autres bases
+
+    Au lancement du programme, le répertoire est vide et l’utilisateur peut entrer une
+commande. Le programme accepte les entrées suivantes : ADD, SEARCH et EXIT.
+
+• ADD : enregistrer un nouveau contact
+    ◦ Si l’utilisateur entre cette commande, le programme lui demande de remplir
+       une par une les informations du nouveau contact. Une fois tous les champs
+       complétés, le nouveau contact est ajouté au répertoire.
+
+    ◦ Un contact possède les champs suivants : first name (prénom), last name
+       (nom de famille), nickname (surnom), phone number (numéro de téléphone),
+       et darkest secret (son plus lourd secret). Les champs d’un contact enregistré ne
+       peuvent être vides.
+
+• SEARCH : affiche le contact demandé
+    ◦ Affiche les contacts enregistrés sous la forme d’une liste de 4 colonnes : index,
+       first name, last name et nickname.
+
+    ◦ Chaque colonne doit faire 10 caractères de long. Elles doivent être séparées
+       par un pipe (’|’). Leur texte est aligné à droite. Si le texte dépasse la largeur
+       de la colonne, il faut le tronquer et remplacer le dernier caractère affiché par
+       un point (’.’).
+
+    ◦ Ensuite, le programme demande à l’utilisateur d’entrer l’index du contact à af-
+       ficher. Si l’index ou son format sont incorrects, gérez cela de manière pertinente.
+       Sinon, affichez les informations du contact, une par ligne.
+
+• EXIT
+    ◦ Le programme quitte et les contacts sont perdus à jamais !
+
+• Toute autre entrée est ignorée.
+
+    Une fois la commande correctement exécutée, le programme attend à nouveau une
+entrée. Il prend fin lorsque l’utilisateur entre EXIT.
+
+Donnez un nom cohérent à votre exécutable.
+
+http://www.cplusplus.com/reference/string/string/ et bien entendu
+http://www.cplusplus.com/reference/iomanip/
+
+                 7
+Chapitre V
+
+Exercice 02 : L’emploi de vos rêves
+
+                                                   Exercice : 02
+                                                 L’emploi de vos rêves
+    Dossier de rendu : ex02/
+    Fichiers à rendre : Makefile, Account.cpp, Account.hpp, tests.cpp
+    Fonctions interdites : Aucune
+
+                     Account.hpp, tests.cpp et le journal sont à télécharger via la page
+                     du module dans l’intranet.
+
+    C’est votre premier jour à GlobalBanksters United. Après avoir réussi les différentes
+phases de recrutement haut la main (merci à cet ami qui a eu la bonne idée de vous
+montrer quelques astuces Microsoft Office), vous avec rejoint l’équipe de dev. Vous avez
+conscience que votre installation éclair d’Adobe Reader a fait forte impression. Ce petit
+plus a fait toute la différence et vous a permis de vaincre vos ennemis (oui, les autres
+candidats) ! Vous avez réussi !
+
+    C’est pas tout mais votre responsable vient de vous confier du travail. Votre première
+mission : recréer un fichier manquant. Quelque chose a mal tourné et un fichier source
+a été supprimé par erreur. Malheureusement, vos collègues ne connaissent pas Git et se
+servent de clés USB pour se partager le code. Il serait sensé de partir de cet endroit dès
+maintenant. Malgré tout, vous décidez de rester et de relever le défi.
+
+    On vous transmet quelques fichiers. Compiler tests.cpp vous confirme que le fichier
+manquant est Account.cpp. Heureusement, le fichier d’en-tête Account.hpp est indemne,
+ainsi qu’un journal (fichier de log). Peut-être pourriez-vous utiliser ce dernier afin de com-
+prendre comment était implémentée la classe Account (compte bancaire).
+
+    Vous commencez à refaire le fichier Account.cpp. En quelques minutes à peine, vous
+
+                                                        8
+C++ - Module 00               Namespaces, classes, fonctions membres, stdio streams,
+                                    listes d’initialisation, static, const, et autres bases
+
+avez tapé des lignes de C++ de génie. Après quelques compilations ratées, votre pro-
+gramme passe les tests. Sa sortie correspond à la perfection à celle contenue dans le
+journal (sauf pour l’horodatage, qui sera forcément différent étant donné que les tests
+sauvegardés dans le journal ont été faits bien avant votre arrivée).
+
+Bon sang, mais quel talent !
+
+L’ordre dans lequel les destructeurs sont appelés peut différer selon
+votre compilateur/système d’exploitation. Ainsi, vos destructeurs
+peuvent être appelés dans l’ordre inverse.
+
+Vous pouvez valider ce module sans l’exercice 02.
+
+                              9
+Chapitre VI
+Submission and peer-evaluation
+
+    Rendez votre travail sur votre dépôt Git comme d’habitude. Seul le travail présent
+sur votre dépôt sera évalué en soutenance. Vérifiez bien les noms de vos dossiers et de
+vos fichiers afin que ces derniers soient conformes aux demandes du sujet.
+
+                     ???????????? XXXXXXXXXX = $3$$f15bc138aca1e76ec6f4cfd0797ec037
+
+                                                       10
+

+ 72 - 0
Module_00/tests.cpp

@@ -0,0 +1,72 @@
+// ************************************************************************** //
+//                                                                            //
+//                tests.cpp for GlobalBanksters United                        //
+//                Created on  : Thu Nov 20 23:45:02 1989                      //
+//                Last update : Wed Jan 04 09:23:52 1992                      //
+//                Made by : Brad "Buddy" McLane <bm@gbu.com>                  //
+//                                                                            //
+// ************************************************************************** //
+
+#include <vector>
+#include <algorithm>
+#include <functional>
+#include "Account.hpp"
+
+
+int		main( void ) {
+
+	typedef std::vector<Account::t>							  accounts_t;
+	typedef std::vector<int>								  ints_t;
+	typedef std::pair<accounts_t::iterator, ints_t::iterator> acc_int_t;
+
+	int	const				amounts[]	= { 42, 54, 957, 432, 1234, 0, 754, 16576 };
+	size_t const			amounts_size( sizeof(amounts) / sizeof(int) );
+	accounts_t				accounts( amounts, amounts + amounts_size );
+	accounts_t::iterator	acc_begin	= accounts.begin();
+	accounts_t::iterator	acc_end		= accounts.end();
+
+	int	const			d[]			= { 5, 765, 564, 2, 87, 23, 9, 20 };
+	size_t const		d_size( sizeof(d) / sizeof(int) );
+	ints_t				deposits( d, d + d_size );
+	ints_t::iterator	dep_begin	= deposits.begin();
+	ints_t::iterator	dep_end		= deposits.end();
+
+	int	const			w[]			= { 321, 34, 657, 4, 76, 275, 657, 7654 };
+	size_t const		w_size( sizeof(w) / sizeof(int) );
+	ints_t				withdrawals( w, w + w_size );
+	ints_t::iterator	wit_begin	= withdrawals.begin();
+	ints_t::iterator	wit_end		= withdrawals.end();
+
+	Account::displayAccountsInfos();
+	std::for_each( acc_begin, acc_end, std::mem_fun_ref( &Account::displayStatus ) );
+
+	for ( acc_int_t it( acc_begin, dep_begin );
+		  it.first != acc_end && it.second != dep_end;
+		  ++(it.first), ++(it.second) ) {
+
+		(*(it.first)).makeDeposit( *(it.second) );
+	}
+
+	Account::displayAccountsInfos();
+	std::for_each( acc_begin, acc_end, std::mem_fun_ref( &Account::displayStatus ) );
+
+	for ( acc_int_t it( acc_begin, wit_begin );
+		  it.first != acc_end && it.second != wit_end;
+		  ++(it.first), ++(it.second) ) {
+
+		(*(it.first)).makeWithdrawal( *(it.second) );
+	}
+
+	Account::displayAccountsInfos();
+	std::for_each( acc_begin, acc_end, std::mem_fun_ref( &Account::displayStatus ) );
+
+	return 0;
+}
+
+
+// ************************************************************************** //
+// vim: set ts=4 sw=4 tw=80 noexpandtab:                                      //
+// -*- indent-tabs-mode:t;                                                   -*-
+// -*- mode: c++-mode;                                                       -*-
+// -*- fill-column: 75; comment-column: 75;                                  -*-
+// ************************************************************************** //

+ 424 - 0
Module_01/en.subject.pdf

@@ -0,0 +1,424 @@
+          C++ - Module 01
+
+ Memory allocation, pointers to members,
+      references and switch statements
+
+                                       Summary:
+This document contains the exercises of Module 01 from C++ modules.
+
+                                     Version: 10.1
+Contents
+
+I   Introduction                       2
+
+II  General rules                      3
+
+III Exercise 00: BraiiiiiiinnnzzzZ     6
+
+IV Exercise 01: Moar brainz!           7
+
+V   Exercise 02: HI THIS IS BRAIN      8
+
+VI Exercise 03: Unnecessary violence   9
+
+VII Exercise 04: Sed is for losers     11
+
+VIII Exercise 05: Harl 2.0             12
+
+IX Exercise 06: Harl filter            14
+
+X   Submission and peer-evaluation     15
+
+                                    1
+Chapter I
+Introduction
+
+C++ is a general-purpose programming language created by Bjarne Stroustrup as an ex-
+tension of the C programming language, or "C with Classes" (source: Wikipedia).
+
+    The goal of these modules is to introduce you to Object-Oriented Programming.
+This will be the starting point of your C++ journey. Many languages are recommended
+for learning OOP. We have chosen C++ since it is derived from your old friend, C.
+Because this is a complex language, and in order to keep things simple, your code will
+comply with the C++98 standard.
+
+    We are aware that modern C++ is very different in many aspects. So if you want to
+become a proficient C++ developer, it is up to you to go further after the 42 Common
+Core!
+
+                                                        2
+Chapter II
+
+General rules
+
+Compiling
+
+    • Compile your code with c++ and the flags -Wall -Wextra -Werror
+    • Your code should still compile if you add the flag -std=c++98
+
+    Formatting and naming conventions
+
+    • The exercise directories will be named this way: ex00, ex01, ... , exn
+    • Name your files, classes, functions, member functions and attributes as required in
+
+       the guidelines.
+    • Write class names in UpperCamelCase format. Files containing class code will
+
+       always be named according to the class name. For instance:
+       ClassName.hpp/ClassName.h, ClassName.cpp, or ClassName.tpp. Then, if you
+       have a header file containing the definition of a class "BrickWall" standing for a
+       brick wall, its name will be BrickWall.hpp.
+    • Unless specified otherwise, every output message must end with a newline character
+       and be displayed to the standard output.
+    • Goodbye Norminette! No coding style is enforced in the C++ modules. You can
+       follow your favorite one. But keep in mind that code your peer evaluators can’t
+       understand is code they can’t grade. Do your best to write clean and readable code.
+
+    Allowed/Forbidden
+
+    You are not coding in C anymore. Time to C++! Therefore:
+
+    • You are allowed to use almost everything from the standard library. Thus, instead
+       of sticking to what you already know, it would be smart to use the C++-ish versions
+       of the C functions you are used to as much as possible.
+
+    • However, you can’t use any other external library. It means C++11 (and derived
+       forms) and Boost libraries are forbidden. The following functions are forbidden
+       too: *printf(), *alloc() and free(). If you use them, your grade will be 0 and
+       that’s it.
+
+                                                        3
+C++ - Module 01            Memory allocation, pointers to members,
+                                     references and switch statements
+
+• Note that unless explicitly stated otherwise, the using namespace <ns_name> and
+  friend keywords are forbidden. Otherwise, your grade will be -42.
+
+• You are allowed to use the STL only in Modules 08 and 09. That means:
+  no Containers (vector/list/map, and so forth) and no Algorithms (anything that
+  requires including the <algorithm> header) until then. Otherwise, your grade will
+  be -42.
+
+A few design requirements
+
+• Memory leakage occurs in C++ too. When you allocate memory (by using the new
+  keyword), you must avoid memory leaks.
+
+• From Module 02 to Module 09, your classes must be designed in the Orthodox
+  Canonical Form, except when explicitly stated otherwise.
+
+• Any function implementation put in a header file (except for function templates)
+  means 0 to the exercise.
+
+• You should be able to use each of your headers independently from others. Thus,
+  they must include all the dependencies they need. However, you must avoid the
+  problem of double inclusion by adding include guards. Otherwise, your grade will
+  be 0.
+
+Read me
+
+• You can add some additional files if you need to (i.e., to split your code). As these
+  assignments are not verified by a program, feel free to do so as long as you turn in
+  the mandatory files.
+
+• Sometimes, the guidelines of an exercise look short but the examples can show
+  requirements that are not explicitly written in the instructions.
+
+• Read each module completely before starting! Really, do it.
+
+• By Odin, by Thor! Use your brain!!!
+
+         Regarding the Makefile for C++ projects, the same rules as in C apply
+         (see the Norm chapter about the Makefile).
+
+         You will have to implement a lot of classes. This can seem tedious,
+         unless you’re able to script your favorite text editor.
+
+                                               4
+C++ - Module 01     Memory allocation, pointers to members,
+                              references and switch statements
+
+You are given a certain amount of freedom to complete the exercises.
+However, follow the mandatory rules and don’t be lazy. You would
+miss a lot of useful information! Do not hesitate to read about
+theoretical concepts.
+
+                 5
+Chapter III
+
+Exercise 00: BraiiiiiiinnnzzzZ
+
+                                                   Exercise : 00
+                                                    BraiiiiiiinnnzzzZ
+    Turn-in directory : ex00/
+    Files to turn in : Makefile, main.cpp, Zombie.{h, hpp}, Zombie.cpp,
+    newZombie.cpp, randomChump.cpp
+    Forbidden functions : None
+
+    First, implement a Zombie class. It has a private string attribute name.
+    Add a member function void announce( void ); to the Zombie class. Zombies
+announce themselves as follows:
+   <name>: BraiiiiiiinnnzzzZ...
+    Do not print the angle brackets (< and >). For a zombie named Foo, the message
+would be:
+   Foo: BraiiiiiiinnnzzzZ...
+    Then, implement the following two functions:
+    • Zombie* newZombie( std::string name );
+
+       This function creates a zombie, names it, and returns it so you can use it outside
+       of the function scope.
+    • void randomChump( std::string name );
+       This function creates a zombie, names it, and makes it announce itself.
+    Now, what is the actual point of the exercise? You have to determine in which case
+it is better to allocate zombies on the stack or the heap.
+
+    Zombies must be destroyed when you no longer need them. The destructor must print
+a message with the name of the zombie for debugging purposes.
+
+                                                        6
+Chapter IV
+Exercise 01: Moar brainz!
+
+                                                   Exercise : 01
+                                                       Moar brainz!
+
+    Turn-in directory : ex01/
+    Files to turn in : Makefile, main.cpp, Zombie.{h, hpp}, Zombie.cpp,
+    zombieHorde.cpp
+    Forbidden functions : None
+
+    Time to create a horde of Zombies!
+    Implement the following function in the appropriate file:
+   Zombie* zombieHorde( int N, std::string name );
+    It must allocate N Zombie objects in a single allocation. Then, it must initialize the
+zombies, giving each of them the name passed as a parameter. The function returns a
+pointer to the first zombie.
+    Implement your own tests to ensure that your zombieHorde() function works as ex-
+pected. Try calling announce() for each of the zombies.
+    Do not forget to use delete to deallocate all the zombies and check for memory
+leaks.
+
+                                                        7
+Chapter V
+
+Exercise 02: HI THIS IS BRAIN
+
+                                                   Exercise : 02
+                                                  HI THIS IS BRAIN
+    Turn-in directory : ex02/
+    Files to turn in : Makefile, main.cpp
+    Forbidden functions : None
+
+    Write a program that contains:
+    • A string variable initialized to "HI THIS IS BRAIN".
+    • stringPTR: a pointer to the string.
+    • stringREF: a reference to the string.
+    Your program must print:
+    • The memory address of the string variable.
+    • The memory address held by stringPTR.
+    • The memory address held by stringREF.
+    And then:
+    • The value of the string variable.
+    • The value pointed to by stringPTR.
+    • The value pointed to by stringREF.
+    That’s all—no tricks. The goal of this exercise is to demystify references, which may
+seem completely new. Although there are some small differences, this is simply another
+syntax for something you already do: address manipulation.
+
+                                                        8
+Chapter VI
+
+Exercise 03: Unnecessary violence
+
+                                                   Exercise : 03
+                                                 Unnecessary violence
+    Turn-in directory : ex03/
+    Files to turn in : Makefile, main.cpp, Weapon.{h, hpp}, Weapon.cpp, HumanA.{h,
+    hpp}, HumanA.cpp, HumanB.{h, hpp}, HumanB.cpp
+    Forbidden functions : None
+
+    Implement a Weapon class that has:
+    • A private attribute type, which is a string.
+    • A getType() member function that returns a constant reference to type.
+    • A setType() member function that sets type using the new value passed as a pa-
+
+       rameter.
+
+    Now, create two classes: HumanA and HumanB. They both have a Weapon and
+a name. They also have a member function attack() that displays (without the angle
+brackets):
+
+   <name> attacks with their <weapon type>
+    HumanA and HumanB are almost identical except for these two small details:
+    • While HumanA takes the Weapon in its constructor, HumanB does not.
+    • HumanB may not always have a weapon, whereas HumanA will always be
+
+       armed.
+
+                                                        9
+C++ - Module 01                                        Memory allocation, pointers to members,
+                                                                 references and switch statements
+
+    If your implementation is correct, executing the following code will print an attack
+with "crude spiked club" followed by a second attack with "some other type of club" for
+both test cases:
+
+int main()    club = Weapon("crude spiked club");
+{
+
+   {
+      Weapon
+
+   HumanA bob("Bob", club);
+   bob.attack();
+   club.setType("some other type of club");
+   bob.attack();
+}
+{
+   Weapon club = Weapon("crude spiked club");
+
+   HumanB jim("Jim");
+   jim.setWeapon(club);
+   jim.attack();
+   club.setType("some other type of club");
+   jim.attack();
+}
+
+   return 0;
+}
+
+Do not forget to check for memory leaks.
+
+                In which case do you think it would be best to use a pointer to
+                Weapon? And a reference to Weapon? Why? Think about it before
+                starting this exercise.
+
+                                                   10
+Chapter VII
+Exercise 04: Sed is for losers
+
+                                                   Exercise : 04
+                                                     Sed is for losers
+
+    Turn-in directory : ex04/
+    Files to turn in : Makefile, main.cpp, *.cpp, *.{h, hpp}
+    Forbidden functions : std::string::replace
+
+    Create a program that takes three parameters in the following order: a filename and
+two strings, s1 and s2.
+
+    It must open the file <filename> and copy its content into a new file
+<filename>.replace, replacing every occurrence of s1 with s2.
+
+    Using C file manipulation functions is forbidden and will be considered cheating. All
+the member functions of the class std::string are allowed, except replace. Use them
+wisely!
+
+    Of course, handle unexpected inputs and errors. You must create and turn in your
+own tests to ensure that your program works as expected.
+
+                                                       11
+Chapter VIII
+
+Exercise 05: Harl 2.0
+
+                                                   Exercise : 05
+                                                          Harl 2.0
+
+    Turn-in directory : ex05/
+    Files to turn in : Makefile, main.cpp, Harl.{h, hpp}, Harl.cpp
+    Forbidden functions : None
+
+    Do you know Harl? We all do, don’t we? In case you don’t, find below the kind of
+comments Harl makes. They are classified by levels:
+
+    • "DEBUG" level: Debug messages contain contextual information. They are mostly
+       used for problem diagnosis.
+       Example: "I love having extra bacon for my 7XL-double-cheese-triple-pickle-special-
+       ketchup burger. I really do!"
+
+    • "INFO" level: These messages contain extensive information. They are helpful for
+       tracing program execution in a production environment.
+       Example: "I cannot believe adding extra bacon costs more money. You didn’t put
+       enough bacon in my burger! If you did, I wouldn’t be asking for more!"
+
+    • "WARNING" level: Warning messages indicate a potential issue in the system.
+       However, it can be handled or ignored.
+       Example: "I think I deserve to have some extra bacon for free. I’ve been coming for
+       years, whereas you started working here just last month."
+
+    • "ERROR" level: These messages indicate that an unrecoverable error has occurred.
+       This is usually a critical issue that requires manual intervention.
+       Example: "This is unacceptable! I want to speak to the manager now."
+
+                                                       12
+C++ - Module 01              Memory allocation, pointers to members,
+                                       references and switch statements
+
+    You are going to automate Harl. It won’t be difficult since he always says the same
+things. You have to create a Harl class with the following private member functions:
+
+• void debug( void );
+• void info( void );
+• void warning( void );
+• void error( void );
+
+    Harl also has a public member function that calls the four member functions above
+depending on the level passed as a parameter:
+
+   void complain( std::string level );
+
+    The goal of this exercise is to use pointers to member functions. This is not a
+suggestion. Harl has to complain without using a forest of if/else if/else. He doesn’t
+think twice!
+
+    Create and turn in tests to show that Harl complains a lot. You can use the examples
+of comments listed above in the subject or choose to use comments of your own.
+
+                         13
+Chapter IX
+
+Exercise 06: Harl filter
+
+                                                   Exercise : 06
+                                                         Harl filter
+
+    Turn-in directory : ex06/
+    Files to turn in : Makefile, main.cpp, Harl.{h, hpp}, Harl.cpp
+    Forbidden functions : None
+
+    Sometimes you don’t want to pay attention to everything Harl says. Implement a
+system to filter what Harl says depending on the log levels you want to listen to.
+
+    Create a program that takes as a parameter one of the four levels. It will display all
+messages from this level and above. For example:
+
+$> ./harlFilter "WARNING"
+[ WARNING ]
+I think I deserve to have some extra bacon for free.
+I've been coming for years, whereas you started working here just last month.
+[ ERROR ]
+This is unacceptable! I want to speak to the manager now.
+$> ./harlFilter "I am not sure how tired I am today..."
+[ Probably complaining about insignificant problems ]
+
+    Although there are several ways to deal with Harl, one of the most effective is to
+SWITCH it off.
+
+    Give the name harlFilter to your executable.
+    You must use, and maybe discover, the switch statement in this exercise.
+
+                     You can pass this module without doing exercise 06.
+
+                                                       14
+Chapter X
+Submission and peer-evaluation
+
+Turn in your assignment in your Git repository as usual. Only the work inside your
+repository will be evaluated during the defense. Don’t hesitate to double-check the names
+of your folders and files to ensure they are correct.
+
+                     ???????????? XXXXXXXXXX = $3$$4f1b9de5b5e60c03dcb4e8c7c7e4072c
+
+                                                       15
+

+ 492 - 0
Module_02/fr.subject.pdf

@@ -0,0 +1,492 @@
+            C++ - Module 02
+
+Polymorphisme ad-hoc, surcharge d’opérateurs
+                et forme canonique
+
+                                           Résumé:
+    Ce document contient les exercices du Module 02 des C++ modules.
+
+                                          Version: 8
+Table des matières
+
+I   Introduction                                      2
+
+II  Consignes générales                               3
+
+III Nouvelle consigne                                 5
+
+IV Exercice 00 : Mon premier canon                    6
+
+V   Exercice 01 : Premiers pas vers une classe utile  8
+
+VI Exercice 02 : Maintenant, on peut parler           10
+
+VII Exercice 03 : BSP                                 12
+
+VIII Submission and peer-evaluation                   14
+
+                         1
+Chapitre I
+Introduction
+
+    C++ is a general-purpose programming language created by Bjarne Stroustrup as an
+extension of the C programming language, or "C with Classes" (source : Wikipedia).
+
+    C++ est un langage de programmation compilé permettant la programmation sous
+de multiples paradigmes, dont la programmation procédurale, la programmation orientée
+objet et la programmation générique. Ses bonnes performances, et sa compatibilité avec le
+C en font un des langages de programmation les plus utilisés dans les applications où la
+performance est critique (source : Wikipedia).
+
+    Ces modules ont pour but de vous introduire à la Programmation Orientée Objet.
+Plusieurs langages sont recommandés pour l’apprentissage de l’OOP. Du fait qu’il soit
+dérivé de votre bon vieil ami le C, nous avons choisi le langage C++. Toutefois, étant un
+langage complexe et afin de ne pas vous compliquer la tâche, vous vous conformerez au
+standard C++98.
+
+    Nous avons conscience que le C++ moderne est différent sur bien des aspects. Si vous
+souhaitez pousser votre maîtrise du C++, c’est à vous de creuser après le tronc commun
+de 42 !
+
+                                                        2
+Chapitre II
+
+Consignes générales
+
+    Compilation
+
+     • Compilez votre code avec c++ et les flags -Wall -Wextra -Werror
+     • Votre code doit compiler si vous ajoutez le flag -std=c++98
+
+    Format et conventions de nommage
+
+     • Les dossiers des exercices seront nommés ainsi : ex00, ex01, ... , exn
+     • Nommez vos fichiers, vos classes, vos fonctions, vos fonctions membres et vos at-
+
+        tributs comme spécifié dans les consignes.
+     • Rédigez vos noms de classe au format UpperCamelCase. Les fichiers contenant
+
+        le code d’une classe porteront le nom de cette dernière. Par exemple :
+        NomDeClasse.hpp/NomDeClasse.h, NomDeClasse.cpp, ou NomDeClasse.tpp.
+        Ainsi, si un fichier d’en-tête contient la définition d’une classe "BrickWall", son
+        nom sera BrickWall.hpp.
+     • Sauf si spécifié autrement, tous les messages doivent être terminés par un retour
+        à la ligne et être affichés sur la sortie standard.
+     • Ciao Norminette ! Aucune norme n’est imposée durant les modules C++. Vous
+        pouvez suivre le style de votre choix. Mais ayez à l’esprit qu’un code que vos pairs
+        ne peuvent comprendre est un code que vos pairs ne peuvent évaluer. Faites donc
+        de votre mieux pour produire un code propre et lisible.
+
+    Ce qui est autorisé et ce qui ne l’est pas
+
+    Le langage C, c’est fini pour l’instant. Voici l’heure de se mettre au C++ ! Par consé-
+quent :
+
+     • Vous pouvez avoir recours à quasi l’ensemble de la bibliothèque standard. Donc
+        plutôt que de rester en terrain connu, essayez d’utiliser le plus possible les versions
+        C++ des fonctions C dont vous avec l’habitude.
+
+     • Cependant, vous ne pouvez avoir recours à aucune autre bibliothèque externe.
+        Ce qui signifie que C++11 (et dérivés) et l’ensemble Boost sont interdits. Aussi,
+        certaines fonctions demeurent interdites. Utiliser les fonctions suivantes résultera
+
+                                                        3
+C++ - Module 02  Polymorphisme ad-hoc, surcharge d’opérateurs
+                                                    et forme canonique
+
+  en la note de 0 : *printf(), *alloc() et free().
+
+• Sauf si explicitement indiqué autrement, les mots-clés using namespace <ns_name>
+  et friend sont interdits. Leur usage résultera en la note de -42.
+
+• Vous n’avez le droit à la STL que dans les Modules 08 et 09. D’ici là,
+  l’usage des Containers (vector/list/map/etc.) et des Algorithmes (tout ce qui
+  requiert d’inclure <algorithm>) est interdit. Dans le cas contraire, vous obtiendrez
+  la note de -42.
+
+Quelques obligations côté conception
+
+• Les fuites de mémoires existent aussi en C++. Quand vous allouez de la mémoire
+  (en utilisant le mot-clé new), vous ne devez pas avoir de memory leaks.
+
+• Du Module 02 au Module 09, vos classes devront se conformer à la forme cano-
+  nique, dite de Coplien, sauf si explicitement spécifié autrement.
+
+• Une fonction implémentée dans un fichier d’en-tête (hormis dans le cas de fonction
+  template) équivaudra à la note de 0.
+
+• Vous devez pouvoir utiliser vos fichiers d’en-tête séparément les uns des autres.
+  C’est pourquoi ils devront inclure toutes les dépendances qui leur seront néces-
+  saires. Cependant, vous devez éviter le problème de la double inclusion en les
+  protégeant avec des include guards. Dans le cas contraire, votre note sera de 0.
+
+Read me
+
+• Si vous en avez le besoin, vous pouvez rendre des fichiers supplémentaires (par
+  exemple pour séparer votre code en plus de fichiers). Vu que votre travail ne sera
+  pas évalué par un programme, faites ce qui vous semble le mieux du moment que
+  vous rendez les fichiers obligatoires.
+
+• Les consignes d’un exercice peuvent avoir l’air simple mais les exemples contiennent
+  parfois des indications supplémentaires qui ne sont pas explicitement demandées.
+
+• Lisez entièrement chaque module avant de commencer ! Vraiment.
+
+• Par Odin, par Thor ! Utilisez votre cervelle ! ! !
+
+         Vous aurez à implémenter un bon nombre de classes, ce qui pourrait
+         s’avérer ardu... ou pas ! Il y a peut-être moyen de vous simplifier
+         la vie grâce à votre éditeur de texte préféré.
+
+         Vous êtes assez libre quant à la manière de résoudre les exercices.
+         Toutefois, respectez les consignes et ne vous en tenez pas au strict
+         minimum, vous pourriez passer à côté de notions intéressantes.
+         N’hésitez pas à lire un peu de théorie.
+
+                 4
+Chapitre III
+Nouvelle consigne
+
+    À partir de maintenant, vos classes devront impérativement se conformer à la forme
+canonique de Coplien, sauf en cas d’indication contraire. Cela signifie qu’elles devront
+comporter les quatre fonctions membres suivantes :
+
+     • Constructeur par défaut
+     • Constructeur de recopie
+     • Opérateur d’affectation
+     • Destructeur
+    Séparer le code de vos classes dans deux fichiers. Le fichier d’en-tête (.hpp/.h) contient
+la définition de la classe, tandis que le fichier source (.cpp) contient son implémentation.
+
+                                                        5
+Chapitre IV
+
+Exercice 00 : Mon premier canon
+
+                                                   Exercice : 00
+                                                  Mon premier canon
+    Dossier de rendu : ex00/
+    Fichiers à rendre : Makefile, main.cpp, Fixed.{h, hpp}, Fixed.cpp
+    Fonctions interdites : Aucune
+
+    Si vous pensiez connaître les entiers et les flottants, cet article de 3 pages (1, 2, 3)
+vous montrera que ce n’est sans doute pas le cas. Allez, lisez-le.
+
+    Jusqu’à aujourd’hui, tous les nombres utilisés dans votre code étaient soit des entiers,
+soit des flottants, soit éventuellement leurs dérivés (short, char, long, double, etc.).
+Après avoir lu l’article ci-dessus, il paraît évident d’affirmer que les caractéristiques des
+entiers et des nombres à virgule flottante sont opposées.
+
+    Mais aujourd’hui, les choses vont changer. Vous allez découvrir une notion inédite et
+passionnante : la représentation des nombres en virgule fixe ! À jamais absents des
+types scalaires de la plupart des langages, les nombres à virgule fixe offrent un équilibre
+intéressant entre performance, exactitude, portée et précision. Cela explique pourquoi
+ces nombres sont largement utilisés dans l’imagerie numérique, le domaine du son ou la
+programmation scientifique, pour n’en citer que trois.
+
+    Étant donné que le C++ ne possède pas de nombres à virgule fixe, vous allez les
+ajouter. Cet article de Berkeley est un bon point de départ. Si vous ne savez pas ce qu’est
+l’Université de Berkeley, lisez cette partie de sa page Wikipédia.
+
+                                                        6
+C++ - Module 02                            Polymorphisme ad-hoc, surcharge d’opérateurs
+                                                                              et forme canonique
+
+Créez une classe sous forme canonique pour représenter un nombre à virgule fixe.
+
+• Membres privés :
+    ◦ Un entier pour stocker la valeur du nombre en virgule fixe.
+    ◦ Un entier constant statique pour stocker le nombre de bits de la partie
+       fractionnaire, et dont la valeur sera toujours le littéral entier 8.
+
+• Membres publics :
+    ◦ Un constructeur par défaut qui initialisera la valeur du nombre à virgule fixe
+       à 0.
+    ◦ Un constructeur de recopie.
+    ◦ Une surcharge de l’opérateur d’affectation.
+    ◦ Un destructeur.
+    ◦ Une fonction membre int getRawBits( void ) const;
+       qui retourne la valeur du nombre à virgule fixe sans la convertir.
+    ◦ Une fonction membre void setRawBits( int const raw );
+       qui initialise la valeur du nombre à virgule fixe avec celle passée en paramètre.
+
+Exécuter ce code :
+
+#include <iostream>
+
+int           main( void ) {
+
+Fixed a;
+Fixed b( a );
+Fixed c;
+
+c = b;
+
+std::cout << a.getRawBits() << std::endl;
+std::cout << b.getRawBits() << std::endl;
+std::cout << c.getRawBits() << std::endl;
+
+   return 0;
+}
+
+  Devrait afficher ce résultat :
+
+$> ./a.out
+Default constructor called
+Copy constructor called
+Copy assignment operator called // <-- This line may be missing depending on your implementation
+getRawBits member function called
+Default constructor called
+Copy assignment operator called
+getRawBits member function called
+getRawBits member function called
+0
+getRawBits member function called
+0
+getRawBits member function called
+0
+Destructor called
+Destructor called
+Destructor called
+$>
+
+                                           7
+Chapitre V
+
+Exercice 01 : Premiers pas vers une
+classe utile
+
+                                                   Exercice : 01
+                                         Premiers pas vers une classe utile
+    Dossier de rendu : ex01/
+    Fichiers à rendre : Makefile, main.cpp, Fixed.{h, hpp}, Fixed.cpp
+    Fonctions Autorisées : roundf (from <cmath>)
+
+    L’exercice précédent était un bon point de départ mais notre classe n’a pour l’instant
+pas beaucoup d’intérêt. Elle peut seulement représenter la valeur 0.0.
+
+    Ajoutez à votre classe les constructeurs et les fonctions membres suivants en public :
+
+     • Un constructeur prenant un entier constant en paramètre et qui convertit celui-
+        ci en virgule fixe. Le nombre de bits de la partie fractionnaire est initialisé à 8
+        comme dans l’exercice 00.
+
+     • Un constructeur prenant un flottant constant en paramètre et qui convertit
+        celui-ci en virgule fixe. Le nombre de bits de la partie fractionnaire est initialisé à
+        8 comme dans l’exercice 00.
+
+     • Une fonction membre float toFloat( void ) const;
+        qui convertit la valeur en virgule fixe en nombre à virgule flottante.
+
+     • Une fonction membre int toInt( void ) const;
+        qui convertit la valeur en virgule fixe en nombre entier.
+
+    Ajoutez également la fonction suivante à vos fichiers de la classe Fixed :
+
+     • Une surcharge de l’opérateur d’insertion («) qui insère une représentation en vir-
+        gule flottante du nombre à virgule fixe dans le flux de sortie (objet output stream)
+        passé en paramètre.
+
+                                                        8
+C++ - Module 02                          Polymorphisme ad-hoc, surcharge d’opérateurs
+                                                                            et forme canonique
+
+Exécuter ce code :
+
+#include <iostream>
+
+int main( void ) {
+
+Fixed            a;
+
+Fixed const b( 10 );
+
+Fixed const c( 42.42f );
+
+Fixed const d( b );
+
+a = Fixed( 1234.4321f );
+
+std::cout << "a is " << a << std::endl;
+std::cout << "b is " << b << std::endl;
+std::cout << "c is " << c << std::endl;
+std::cout << "d is " << d << std::endl;
+
+std::cout << "a is " << a.toInt() << " as integer" << std::endl;
+std::cout << "b is " << b.toInt() << " as integer" << std::endl;
+std::cout << "c is " << c.toInt() << " as integer" << std::endl;
+std::cout << "d is " << d.toInt() << " as integer" << std::endl;
+
+      return 0;
+}
+
+  Devrait afficher ce résultat :
+
+$> ./a.out
+Default constructor called
+Int constructor called
+Float constructor called
+Copy constructor called
+Copy assignment operator called
+Float constructor called
+Copy assignment operator called
+Destructor called
+a is 1234.43
+b is 10
+c is 42.4219
+d is 10
+a is 1234 as integer
+b is 10 as integer
+c is 42 as integer
+d is 10 as integer
+Destructor called
+Destructor called
+Destructor called
+Destructor called
+$>
+
+                                         9
+Chapitre VI
+
+Exercice 02 : Maintenant, on peut
+parler
+
+                                                   Exercice : 02
+                                             Maintenant, on peut parler
+    Dossier de rendu : ex02/
+    Fichiers à rendre : Makefile, main.cpp, Fixed.{h, hpp}, Fixed.cpp
+    Fonctions Autorisées : roundf (from <cmath>)
+
+    Ajoutez à votre classe des fonctions membres publiques afin de surcharger les opéra-
+teurs suivants :
+
+     • Les 6 opérateur de comparaison : >, <, >=, <=, == et !=.
+     • Les 4 opérateurs de arithmétiques : +, -, *, et /.
+     • Les 4 opérateurs d’incrémentation et de décrémentation (pré-incrémentation et
+
+        post-incrémentation, pré-décrémentation et post-décrémentation) qui diminueront
+        la valeur du nombre à virgule fixe d’unité ϵ tel que 1 + ϵ > 1.
+    Ajoutez à votre classe ces quatre fonctions membres publiques surchargées :
+     • Une fonction membre statique min prenant en paramètres deux références sur des
+        nombres à virgule fixe et qui retourne le plus petit d’entre eux.
+     • Une fonction membre statique min prenant en paramètres deux références sur des
+        nombres à virgule fixe constants et qui retourne le plus petit d’entre eux.
+     • Une fonction membre statique max prenant en paramètres deux références sur des
+        nombres à virgule fixe et qui retourne le plus grand d’entre eux.
+     • Une fonction membre statique max prenant en paramètres deux références sur des
+        nombres à virgule fixe constants et qui retourne le plus grand d’entre eux.
+
+                                                       10
+C++ - Module 02                      Polymorphisme ad-hoc, surcharge d’opérateurs
+                                                                        et forme canonique
+
+C’est à vous de tester chaque fonctionnalité de votre code. Mais exécuter ce code :
+
+#include <iostream>
+
+int  main( void ) {
+
+     Fixed           a;
+     Fixed const     b( Fixed( 5.05f ) * Fixed( 2 ) );
+
+     std::cout << a << std::endl;
+     std::cout << ++a << std::endl;
+     std::cout << a << std::endl;
+     std::cout << a++ << std::endl;
+     std::cout << a << std::endl;
+
+     std::cout << b << std::endl;
+
+     std::cout << Fixed::max( a, b ) << std::endl;
+
+      return 0;
+}
+
+    Devra afficher ce résultat (pour plus de lisibilité, les messages du constructeur et du
+destructeur ont été retirés) :
+
+  $> ./a.out
+  0
+  0.00390625
+  0.00390625
+  0.00390625
+  0.0078125
+  10.1016
+  10.1016
+  $>
+
+                 Si vous effectuez une division par 0, il est acceptable que le
+                 programme crash.
+
+                                                    11
+Chapitre VII
+Exercice 03 : BSP
+
+                                                   Exercice : 03
+                                                            BSP
+
+    Dossier de rendu : ex03/
+    Fichiers à rendre : Makefile, main.cpp, Fixed.{h, hpp}, Fixed.cpp,
+    Point.{h, hpp}, Point.cpp, bsp.cpp
+    Fonctions Autorisées : roundf (from <cmath>)
+
+    Maintenant que vous avez une classe Fixed fonctionnelle, ce serait sympa de l’utiliser
+non ?
+
+    Implémentez une fonction qui indique si un point donné est à l’intérieur d’un triangle.
+Super utile, n’est-ce pas ?
+
+                     BSP signifie Binary Space Partitioning. Ne me remerciez pas. :)
+
+                     Vous pouvez valider ce module sans l’exercice 03.
+
+                                                       12
+C++ - Module 02     Polymorphisme ad-hoc, surcharge d’opérateurs
+                                                       et forme canonique
+
+    Premièrement, créez une classe Point sous forme canonique pour représenter un point
+2D :
+
+• Membres privés :
+
+    ◦ Un attribut Fixed constant x.
+    ◦ Un attribut Fixed constant y.
+    ◦ Et tout ce qui peut vous être utile.
+
+• Membres publics :
+
+◦ Un constructeur par défaut qui initialise x et y à 0.
+◦ Un constructeur prenant deux flottants constants en paramètres et initialisant
+
+  x et y avec ces derniers.
+◦ Un constructeur de recopie.
+◦ Une surcharge de l’opérateur d’affectation.
+◦ Un destructeur.
+◦ Et tout ce qui peut vous être utile.
+
+Pour conclure, implémentez la fonction suivante dans le fichier correspondant :
+ bool bsp( Point const a, Point const b, Point const c, Point const point);
+
+     • a, b, c : Les sommets de notre cher triangle.
+
+     • point : Le point à évaluer.
+
+     • Retourne : True si le point est à l’intérieur du triangle. False dans le cas contraire.
+        Cela veut dire que, si le point est un sommet ou placé sur une arrête, la fonction
+        retournera False.
+
+    Écrivez et rendez vos propres tests afin de démontrer que votre classe fonctionne
+comme demandé.
+
+                    13
+Chapitre VIII
+Submission and peer-evaluation
+
+    Rendez votre travail dans votre dépôt Git comme d’habitude. Seul le travail présent
+sur votre dépôt sera évalué en soutenance. Vérifiez bien les noms de vos dossiers et de
+vos fichiers afin que ces derniers soient conformes aux demandes du sujet.
+
+                     ???????????? XXXXXXXXXX = $3$$d6f957a965f8361750a3ba6c97554e9f
+
+                                                       14
+

+ 313 - 0
Module_03/en.subject.pdf

@@ -0,0 +1,313 @@
+           C++ - Module 03
+
+                   Inheritance
+
+                                       Summary:
+This document contains the exercises of Module 03 from C++ modules.
+
+                                      Version: 7.1
+Contents
+
+I   Introduction                     2
+
+II  General rules                    3
+
+III Exercise 00: Aaaaand... OPEN!    6
+
+IV Exercise 01: Serena, my love!     8
+
+V   Exercise 02: Repetitive work     9
+
+VI Exercise 03: Now it’s weird!      10
+
+VII Submission and Peer-Evaluation   12
+
+                                  1
+Chapter I
+Introduction
+
+C++ is a general-purpose programming language created by Bjarne Stroustrup as an ex-
+tension of the C programming language, or "C with Classes" (source: Wikipedia).
+
+    The goal of these modules is to introduce you to Object-Oriented Programming.
+This will be the starting point of your C++ journey. Many languages are recommended
+to learn OOP, but we decided to choose C++ since it’s derived from your old friend C.
+Because this is a complex language, and in order to keep things simple, your code will
+comply with the C++98 standard.
+
+    We are aware that modern C++ is very different in many aspects. So, if you want
+to become a proficient C++ developer, it’s up to you to go further after the 42 Common
+Core!
+
+                                                        2
+Chapter II
+
+General rules
+
+Compiling
+
+    • Compile your code with c++ and the flags -Wall -Wextra -Werror
+    • Your code should still compile if you add the flag -std=c++98
+
+    Formatting and naming conventions
+
+    • The exercise directories will be named this way: ex00, ex01, ... , exn
+    • Name your files, classes, functions, member functions and attributes as required in
+
+       the guidelines.
+    • Write class names in UpperCamelCase format. Files containing class code will
+
+       always be named according to the class name. For instance:
+       ClassName.hpp/ClassName.h, ClassName.cpp, or ClassName.tpp. Then, if you
+       have a header file containing the definition of a class "BrickWall" standing for a
+       brick wall, its name will be BrickWall.hpp.
+    • Unless specified otherwise, every output message must end with a newline character
+       and be displayed to the standard output.
+    • Goodbye Norminette! No coding style is enforced in the C++ modules. You can
+       follow your favorite one. But keep in mind that code your peer evaluators can’t
+       understand is code they can’t grade. Do your best to write clean and readable code.
+
+    Allowed/Forbidden
+
+    You are not coding in C anymore. Time to C++! Therefore:
+
+    • You are allowed to use almost everything from the standard library. Thus, instead
+       of sticking to what you already know, it would be smart to use the C++-ish versions
+       of the C functions you are used to as much as possible.
+
+    • However, you can’t use any other external library. It means C++11 (and derived
+       forms) and Boost libraries are forbidden. The following functions are forbidden
+       too: *printf(), *alloc() and free(). If you use them, your grade will be 0 and
+       that’s it.
+
+                                                        3
+C++ - Module 03  Inheritance
+
+• Note that unless explicitly stated otherwise, the using namespace <ns_name> and
+  friend keywords are forbidden. Otherwise, your grade will be -42.
+
+• You are allowed to use the STL only in Modules 08 and 09. That means:
+  no Containers (vector/list/map, and so forth) and no Algorithms (anything that
+  requires including the <algorithm> header) until then. Otherwise, your grade will
+  be -42.
+
+A few design requirements
+
+• Memory leakage occurs in C++ too. When you allocate memory (by using the new
+  keyword), you must avoid memory leaks.
+
+• From Module 02 to Module 09, your classes must be designed in the Orthodox
+  Canonical Form, except when explicitly stated otherwise.
+
+• Any function implementation put in a header file (except for function templates)
+  means 0 to the exercise.
+
+• You should be able to use each of your headers independently from others. Thus,
+  they must include all the dependencies they need. However, you must avoid the
+  problem of double inclusion by adding include guards. Otherwise, your grade will
+  be 0.
+
+Read me
+
+• You can add some additional files if you need to (i.e., to split your code). As these
+  assignments are not verified by a program, feel free to do so as long as you turn in
+  the mandatory files.
+
+• Sometimes, the guidelines of an exercise look short but the examples can show
+  requirements that are not explicitly written in the instructions.
+
+• Read each module completely before starting! Really, do it.
+
+• By Odin, by Thor! Use your brain!!!
+
+Regarding the Makefile for C++ projects, the same rules as in C apply
+(see the Norm chapter about the Makefile).
+
+You will have to implement a lot of classes. This can seem tedious,
+unless you’re able to script your favorite text editor.
+
+                                      4
+C++ - Module 03     Inheritance
+
+You are given a certain amount of freedom to complete the exercises.
+However, follow the mandatory rules and don’t be lazy. You would
+miss a lot of useful information! Do not hesitate to read about
+theoretical concepts.
+
+                 5
+Chapter III
+
+Exercise 00: Aaaaand... OPEN!
+
+                                                   Exercise : 00
+                                                   Aaaaand... OPEN!
+    Turn-in directory : ex00/
+    Files to turn in : Makefile, main.cpp, ClapTrap.{h, hpp}, ClapTrap.cpp
+    Forbidden functions : None
+
+    First, you have to implement a class! How original!
+
+    It will be called ClapTrap and will have the following private attributes initialized
+to the values specified in brackets:
+
+    • Name, which is passed as a parameter to the constructor
+    • Hit points (10), representing the health of the ClapTrap
+    • Energy points (10)
+    • Attack damage (0)
+    Add the following public member functions so that the ClapTrap behaves more real-
+istically:
+    • void attack(const std::string& target);
+    • void takeDamage(unsigned int amount);
+    • void beRepaired(unsigned int amount);
+    When ClapTrap attacks, it causes its target to lose <attack damage> hit points.
+When ClapTrap repairs itself, it regains <amount> hit points. Attacking and repairing
+each cost 1 energy point. Of course, ClapTrap can’t do anything if it has no hit points or
+energy points left. However, since these exercises serve as an introduction, the ClapTrap
+instances should not interact directly with one another, and the parameters will not refer
+to another instance of ClapTrap.
+
+                                                        6
+C++ - Module 03     Inheritance
+
+    In all of these member functions, you need to print a message to describe what hap-
+pens. For example, the attack() function may display something like (of course, without
+the angle brackets):
+
+      ClapTrap <name> attacks <target>, causing <damage> points of damage!
+
+    The constructors and destructor must also display a message, so your peer-evaluators
+can easily see that they have been called.
+
+    Implement and turn in your own tests to ensure your code works as expected.
+
+                 7
+Chapter IV
+
+Exercise 01: Serena, my love!
+
+                                                   Exercise : 01
+
+                                                    Serena, my love!
+    Turn-in directory : ex01/
+    Files to turn in : Files from the previous exercise + ScavTrap.{h, hpp},
+    ScavTrap.cpp
+    Forbidden functions : None
+
+    Because you can never have enough ClapTraps, you will now create a derived robot.
+It will be named ScavTrap and will inherit the constructors and destructor from Clap-
+Trap. However, its constructors, destructor, and attack() will print different messages.
+After all, ClapTraps are aware of their individuality.
+
+    Note that proper construction/destruction chaining must be shown in your tests.
+When a ScavTrap is created, the program starts by constructing a ClapTrap. Destruc-
+tion occurs in reverse order. Why?
+
+    ScavTrap will use the attributes of ClapTrap (update ClapTrap accordingly) and
+must initialize them to:
+
+    • Name, which is passed as a parameter to the constructor
+    • Hit points (100), representing the health of the ClapTrap
+    • Energy points (50)
+    • Attack damage (20)
+    ScavTrap will also have its own special ability:
+
+      void guardGate();
+
+This member function will display a message indicating that ScavTrap is now in Gate
+keeper mode.
+
+    Don’t forget to add more tests to your program.
+
+                                                        8
+Chapter V
+
+Exercise 02: Repetitive work
+
+                                                   Exercise : 02
+                                                     Repetitive work
+    Turn-in directory : ex02/
+    Files to turn in : Files from previous exercises + FragTrap.{h, hpp},
+    FragTrap.cpp
+    Forbidden functions : None
+
+    Making ClapTraps is probably starting to get on your nerves.
+    Now, implement a FragTrap class that inherits from ClapTrap. It is very similar to
+ScavTrap. However, its construction and destruction messages must be different. Proper
+construction/destruction chaining must be shown in your tests. When a FragTrap is cre-
+ated, the program starts by constructing a ClapTrap. Destruction occurs in reverse order.
+    Same goes for the attributes, but with different values this time:
+    • Name, which is passed as a parameter to the constructor
+    • Hit points (100), representing the health of the ClapTrap
+    • Energy points (100)
+    • Attack damage (30)
+    FragTrap has a special ability too:
+
+      void highFivesGuys(void);
+
+This member function displays a positive high-fives request on the standard output.
+    Again, add more tests to your program.
+
+                                                        9
+Chapter VI
+
+Exercise 03: Now it’s weird!
+
+                                                   Exercise : 03
+                                                     Now it’s weird!
+
+    Turn-in directory : ex03/
+    Files to turn in : Files from previous exercises + DiamondTrap.{h, hpp},
+    DiamondTrap.cpp
+    Forbidden functions : None
+
+    In this exercise, you will create a monster: a ClapTrap that’s half FragTrap, half Scav-
+Trap. It will be named DiamondTrap, and it will inherit from both FragTrap AND
+ScavTrap. This is so risky!
+
+    The DiamondTrap class will have a private attribute named name. This attribute must
+have exactly the same variable name as in the ClapTrap base class (without referring to
+the robot’s name).
+
+    To be clearer, here are two examples:
+If ClapTrap’s variable is name, give the DiamondTrap’s variable the name name.
+If ClapTrap’s variable is _name, give the DiamondTrap’s variable the name _name.
+
+    Its attributes and member functions will be inherited from its parent classes:
+    • Name, which is passed as a parameter to a constructor
+    • ClapTrap::name (parameter of the constructor + "_clap_name" suffix)
+    • Hit points (FragTrap)
+    • Energy points (ScavTrap)
+    • Attack damage (FragTrap)
+    • attack() (ScavTrap)
+
+                                                       10
+C++ - Module 03                                           Inheritance
+
+    In addition to the special functions from both parent classes, DiamondTrap will have
+its own special ability:
+
+      void whoAmI();
+
+This member function will display both its name and its ClapTrap name.
+
+    Of course, the ClapTrap instance of DiamondTrap will be created once, and only once.
+Yes, there’s a trick.
+
+    Again, add more tests to your program.
+
+Do you know the -Wshadow and -Wno-shadow compiler flags?
+
+You can pass this module without completing exercise 03.
+
+                 11
+Chapter VII
+Submission and Peer-Evaluation
+
+Submit your assignment in your Git repository as usual. Only the work within your
+repository will be evaluated during the defense. Don’t hesitate to double-check the names
+of your folders and files to ensure they are correct.
+
+                     ???????????? XXXXXXXXXX = $3$$cf36316f07f871b4f14926007c37d388
+
+                                                       12
+

+ 439 - 0
Module_04/fr.subject.pdf

@@ -0,0 +1,439 @@
+              C++ - Module 04
+
+Polymorphisme par sous-typage, classes abstraites,
+                        interfaces
+
+                                               Résumé:
+        Ce document contient les exercices du Module 04 des C++ modules.
+
+                                             Version: 11
+Table des matières
+
+I   Introduction                                 2
+
+II  Consignes générales                          3
+
+III Exercice 00 : Polymorphisme                  5
+
+IV Exercice 01 : Je ne veux pas brûler le monde  7
+
+V   Exercice 02 : Classe abstraite               9
+
+VI Exercice 03 : Interface & recap               10
+
+VII Submission and peer-evaluation               14
+
+                                    1
+Chapitre I
+Introduction
+
+    C++ is a general-purpose programming language created by Bjarne Stroustrup as an
+extension of the C programming language, or "C with Classes" (source : Wikipedia).
+
+    C++ est un langage de programmation compilé permettant la programmation sous
+de multiples paradigmes, dont la programmation procédurale, la programmation orientée
+objet et la programmation générique. Ses bonnes performances, et sa compatibilité avec le
+C en font un des langages de programmation les plus utilisés dans les applications où la
+performance est critique (source : Wikipedia).
+
+    Ces modules ont pour but de vous introduire à la Programmation Orientée Objet.
+Plusieurs langages sont recommandés pour l’apprentissage de l’OOP. Du fait qu’il soit
+dérivé de votre bon vieil ami le C, nous avons choisi le langage C++. Toutefois, étant un
+langage complexe et afin de ne pas vous compliquer la tâche, vous vous conformerez au
+standard C++98.
+
+    Nous avons conscience que le C++ moderne est différent sur bien des aspects. Si vous
+souhaitez pousser votre maîtrise du C++, c’est à vous de creuser après le tronc commun
+de 42 !
+
+                                                        2
+Chapitre II
+
+Consignes générales
+
+    Compilation
+
+     • Compilez votre code avec c++ et les flags -Wall -Wextra -Werror
+     • Votre code doit compiler si vous ajoutez le flag -std=c++98
+
+    Format et conventions de nommage
+
+     • Les dossiers des exercices seront nommés ainsi : ex00, ex01, ... , exn
+     • Nommez vos fichiers, vos classes, vos fonctions, vos fonctions membres et vos at-
+
+        tributs comme spécifié dans les consignes.
+     • Rédigez vos noms de classe au format UpperCamelCase. Les fichiers contenant
+
+        le code d’une classe porteront le nom de cette dernière. Par exemple :
+        NomDeClasse.hpp/NomDeClasse.h, NomDeClasse.cpp, ou NomDeClasse.tpp.
+        Ainsi, si un fichier d’en-tête contient la définition d’une classe "BrickWall", son
+        nom sera BrickWall.hpp.
+     • Sauf si spécifié autrement, tous les messages doivent être terminés par un retour
+        à la ligne et être affichés sur la sortie standard.
+     • Ciao Norminette ! Aucune norme n’est imposée durant les modules C++. Vous
+        pouvez suivre le style de votre choix. Mais ayez à l’esprit qu’un code que vos pairs
+        ne peuvent comprendre est un code que vos pairs ne peuvent évaluer. Faites donc
+        de votre mieux pour produire un code propre et lisible.
+
+    Ce qui est autorisé et ce qui ne l’est pas
+
+    Le langage C, c’est fini pour l’instant. Voici l’heure de se mettre au C++ ! Par consé-
+quent :
+
+     • Vous pouvez avoir recours à quasi l’ensemble de la bibliothèque standard. Donc
+        plutôt que de rester en terrain connu, essayez d’utiliser le plus possible les versions
+        C++ des fonctions C dont vous avec l’habitude.
+
+     • Cependant, vous ne pouvez avoir recours à aucune autre bibliothèque externe.
+        Ce qui signifie que C++11 (et dérivés) et l’ensemble Boost sont interdits. Aussi,
+        certaines fonctions demeurent interdites. Utiliser les fonctions suivantes résultera
+
+                                                        3
+C++ - Module 04  Polymorphisme par sous-typage, classes abstraites, interfaces
+
+    en la note de 0 : *printf(), *alloc() et free().
+ • Sauf si explicitement indiqué autrement, les mots-clés using namespace <ns_name>
+
+    et friend sont interdits. Leur usage résultera en la note de -42.
+ • Vous n’avez le droit à la STL que dans les Modules 08 et 09. D’ici là,
+
+    l’usage des Containers (vector/list/map/etc.) et des Algorithmes (tout ce qui
+    requiert d’inclure <algorithm>) est interdit. Dans le cas contraire, vous obtiendrez
+    la note de -42.
+
+Quelques obligations côté conception
+
+ • Les fuites de mémoires existent aussi en C++. Quand vous allouez de la mémoire
+    (en utilisant le mot-clé new), vous ne devez pas avoir de memory leaks.
+
+ • Du Module 02 au Module 09, vos classes devront se conformer à la forme cano-
+    nique, dite de Coplien, sauf si explicitement spécifié autrement.
+
+ • Une fonction implémentée dans un fichier d’en-tête (hormis dans le cas de fonction
+    template) équivaudra à la note de 0.
+
+ • Vous devez pouvoir utiliser vos fichiers d’en-tête séparément les uns des autres.
+    C’est pourquoi ils devront inclure toutes les dépendances qui leur seront néces-
+    saires. Cependant, vous devez éviter le problème de la double inclusion en les
+    protégeant avec des include guards. Dans le cas contraire, votre note sera de 0.
+
+Read me
+
+ • Si vous en avez le besoin, vous pouvez rendre des fichiers supplémentaires (par
+    exemple pour séparer votre code en plus de fichiers). Vu que votre travail ne sera
+    pas évalué par un programme, faites ce qui vous semble le mieux du moment que
+    vous rendez les fichiers obligatoires.
+
+ • Les consignes d’un exercice peuvent avoir l’air simple mais les exemples contiennent
+    parfois des indications supplémentaires qui ne sont pas explicitement demandées.
+
+ • Lisez entièrement chaque module avant de commencer ! Vraiment.
+ • Par Odin, par Thor ! Utilisez votre cervelle ! ! !
+
+Vous aurez à implémenter un bon nombre de classes, ce qui pourrait
+s’avérer ardu... ou pas ! Il y a peut-être moyen de vous simplifier
+la vie grâce à votre éditeur de texte préféré.
+
+Vous êtes assez libre quant à la manière de résoudre les exercices.
+Toutefois, respectez les consignes et ne vous en tenez pas au strict
+minimum, vous pourriez passer à côté de notions intéressantes.
+N’hésitez pas à lire un peu de théorie.
+
+                 4
+Chapitre III
+
+Exercice 00 : Polymorphisme
+
+                                                   Exercice : 00
+                                                     Polymorphisme
+
+    Dossier de rendu : ex00/
+    Fichiers à rendre : Makefile, main.cpp, *.cpp, *.{h, hpp}
+    Fonctions interdites : Aucune
+
+    Pour chaque exercice, veuillez fournir les tests les plus complets possible.
+Les constructeurs et les destructeurs de chaque classe doivent afficher des messages qui
+leur sont propres. N’utilisez pas le même message pour toutes les classes.
+
+    Commencez par implémenter une classe simple de base Animal. Elle possède un at-
+tribut protégé :
+
+     • std::string type;
+    Implémentez une classe Dog (chien) qui hérite de Animal.
+    Implémentez une classe Cat (chat) qui hérite de Animal.
+    Ces deux classes dérivées doivent initialiser leur type en fonction de leur nom. Ainsi,
+le type de Dog sera “Dog”, et celui de Cat sera “Cat”. Le type de la classe Animal peut
+être laissé vide ou initialisé avec la valeur de votre choix.
+    Chaque animal doit être capable d’utiliser la fonction membre :
+    makeSound()
+    Elle affichera un son cohérent (les chats n’aboient pas).
+
+                                                        5
+C++ - Module 04  Polymorphisme par sous-typage, classes abstraites, interfaces
+
+    Exécuter ce code devrait afficher les sons propres aux classes Dog et Cat, pas celui de
+la classe Animal.
+
+int main()
+{
+
+      const Animal* meta = new Animal();
+      const Animal* j = new Dog();
+      const Animal* i = new Cat();
+
+      std::cout << j->getType() << " " << std::endl;
+      std::cout << i->getType() << " " << std::endl;
+      i->makeSound(); //will output the cat sound!
+      j->makeSound();
+      meta->makeSound();
+      ...
+
+      return 0;
+}
+
+    Afin de vous assurer d’avoir compris, implémentez une classe WrongCat héritant
+d’une classe WrongAnimal. Dans le code ci-dessus, si vous remplacez l’Animal et le
+Cat par le WrongAnimal et le WrongCat, le WrongCat devrait afficher le son du Wron-
+gAnimal.
+
+    Écrivez et rendez plus de tests que ceux donnés ci-dessus.
+
+                 6
+Chapitre IV
+
+Exercice 01 : Je ne veux pas brûler
+le monde
+
+                                                   Exercice : 01
+                                          Je ne veux pas brûler le monde
+    Dossier de rendu : ex01/
+    Fichiers à rendre : Fichiers de l’exercice précédent + *.cpp, *.{h, hpp}
+    Fonctions interdites : Aucune
+
+    Les constructeurs et les destructeurs de chaque classe doivent afficher des messages
+qui leur sont propres.
+
+    Implémentez une classe Brain (cerveau) contenant un tableau de 100 std::string
+appelé ideas (idées).
+Ainsi, les classes Dog et Cat auront un attribut privé Brain*.
+À la construction, les classes Dog et Cat créeront leur Brain avec new Brain();
+À la destruction, les classes Dog et Cat devront delete leur Brain.
+
+    Dans votre fonction main, créez et remplissez un tableau d’objets Animal dont la
+moitié est composée d’objets Dog et l’autre moitié d’objets Cat. À la fin de l’exécution
+du programme, parcourez ce tableau afin de delete chaque Animal. Vous devez delete
+directement les chiens et les chats en tant qu’Animal. Les destructeurs correspondants
+doivent être appelés dans le bon ordre.
+
+    N’oubliez pas de vérifier que vous n’avez pas de fuites de mémoire.
+    La copie d’un objet Dog ou d’un objet Cat ne doit pas être superficielle. Par consé-
+quent, vous devez vous assurer que vos copies sont bien des copies profondes.
+
+                                                        7
+C++ - Module 04  Polymorphisme par sous-typage, classes abstraites, interfaces
+
+int main()
+{
+
+      const Animal* j = new Dog();
+      const Animal* i = new Cat();
+
+      delete j;//should not create a leak
+      delete i;
+      ...
+
+      return 0;
+}
+
+Écrivez et rendez plus de tests que ceux donnés ci-dessus.
+
+                                           8
+Chapitre V
+Exercice 02 : Classe abstraite
+
+                                                   Exercice : 02
+                                                     Classe abstraite
+    Dossier de rendu : ex02/
+    Fichiers à rendre : Fichiers de l’exercice précédent + *.cpp, *.{h, hpp}
+    Fonctions interdites : Aucune
+
+    Créer des objets Animal ne sert pas à grand-chose au final. Ils ne font aucun bruit !
+    Afin d’éviter les erreurs potentielles, la classe Animal de base ne doit pas être instan-
+ciable. Modifiez-la afin que personne ne puisse l’instancier. Votre code doit fonctionner
+comme avant.
+    Si vous le souhaitez, vous pouvez ajouter la lettre A pour préfixer le nom Animal.
+
+                                                        9
+Chapitre VI
+
+Exercice 03 : Interface & recap
+
+                                                   Exercice : 03
+                                                    Interface & recap
+    Dossier de rendu : ex03/
+    Fichiers à rendre : Makefile, main.cpp, *.cpp, *.{h, hpp}
+    Fonctions interdites : Aucune
+
+    Il n’y a pas d’interfaces en C++98 (ni en C++20). Toutefois, les classes purement
+abstraites sont communément appelées des interfaces. Donc dans ce dernier exercice, afin
+de s’assurer que ce module est maîtrisé, vous implémenterez des interfaces.
+
+    Complétez la définition de la classe AMateria suivante et implémentez les fonctions
+membres nécessaires.
+
+  class AMateria
+  {
+
+        protected:
+                    [...]
+
+        public:
+                    AMateria(std::string const & type);
+                    [...]
+                    std::string const & getType() const; //Returns the materia type
+                    virtual AMateria* clone() const = 0;
+                    virtual void use(ICharacter& target);
+
+  };
+
+                                                       10
+C++ - Module 04  Polymorphisme par sous-typage, classes abstraites, interfaces
+
+    Implémentez les Materias Ice (glace) et Cure (soin) sous forme de classes concrètes.
+Utilisez leur noms en minuscules ("ice" pour Ice, "cure" pour Cure) comme types. Bien
+sûr, leur fonction membre clone() retournera une nouvelle instance de même type (en
+clonant une Materia Ice, on obtient une autre Materia Ice).
+
+    Pour ce qui est de la fonction membre use(ICharacter&), elle affichera :
+
+     • Ice : "* shoots an ice bolt at <name> *"
+     • Cure : "* heals <name>’s wounds *"
+
+    <name> est le nom du Character (personnage) passé en paramètre. N’affichez pas les
+chevrons (< et >).
+
+                     Quand on assigne une Materia à une autre, copier son type n’a pas
+                     grand intérêt.
+
+    Créez la classe concrète Character qui implémentera l’interface suivante :
+
+  class ICharacter
+  {
+
+        public:
+                    virtual ~ICharacter() {}
+                    virtual std::string const & getName() const = 0;
+                    virtual void equip(AMateria* m) = 0;
+                    virtual void unequip(int idx) = 0;
+                    virtual void use(int idx, ICharacter& target) = 0;
+
+  };
+
+    Le Character a un inventaire de 4 items, soit 4 Materias maximum. À la construction,
+l’inventaire est vide. Les Materias sont équipées au premier emplacement vide trouvé, soit
+dans l’ordre suivant : de l’emplacement 0 au 3. Dans le cas où on essaie d’ajouter une
+Materia à un inventaire plein, ou d’utiliser/retirer une Materia qui n’existe pas, ne faites
+rien (cela n’autorise pas les bugs pour autant). La fonction membre unequip() ne doit
+PAS delete la Materia !
+
+                     Occupez-vous des Materias laissées au sol par votre personnage comme
+                     vous le sentez. Vous pouvez enregistrer l’adresse avant d’appeler
+                     unequip(), ou autre, du moment que vous n’avez pas de fuites de
+                     mémoire.
+
+    La fonction membre use(int, ICharacter&) utilisera la Materia de l’emplacement[idx],
+et passera la cible en paramètre à la fonction AMateria::use.
+
+                 11
+C++ - Module 04  Polymorphisme par sous-typage, classes abstraites, interfaces
+
+                     L’inventaire de votre personnage devra pouvoir contenir n’importe
+                     quel type d’objet AMateria.
+
+    Votre Character doit comporter un constructeur prenant son nom en paramètre.
+Toute copie (avec le constructeur par recopie ou l’opérateur d’affectation) d’un Charac-
+ter doit être profonde. Ainsi, lors d’une copie, les Materias du Character doivent être
+delete avant que les nouvelles ne les remplacent dans l’inventaire. Bien évidemment, les
+Materias doivent aussi être supprimées à la destruction d’un Character.
+
+    Créez la classe concrète MateriaSource qui implémentera l’interface suivante :
+
+  class IMateriaSource
+  {
+
+        public:
+                    virtual ~IMateriaSource() {}
+                    virtual void learnMateria(AMateria*) = 0;
+                    virtual AMateria* createMateria(std::string const & type) = 0;
+
+  };
+
+     • learnMateria(AMateria*)
+        Copie la Materia passée en paramètre et la stocke en mémoire afin de la cloner
+        plus tard. Tout comme le Character, la MateriaSource peut contenir 4 Materias
+        maximum. Ces dernières ne sont pas forcément uniques.
+
+     • createMateria(std::string const &)
+        Retourne une nouvelle Materia. Celle-ci est une copie de celle apprise précédem-
+        ment par la MateriaSource et dont le type est le même que celui passé en para-
+        mètre. Retourne 0 si le type est inconnu.
+
+    En bref, votre MateriaSource doit pouvoir apprendre des "modèles" de Materias
+afin de les recréer à volonté. Ainsi, vous serez capable de générer une nouvelle Materia à
+partir de son type sous forme de chaîne de caractères.
+
+                 12
+C++ - Module 04  Polymorphisme par sous-typage, classes abstraites, interfaces
+
+ Exécuter ce code :
+
+int main()
+{
+
+      IMateriaSource* src = new MateriaSource();
+      src->learnMateria(new Ice());
+      src->learnMateria(new Cure());
+
+      ICharacter* me = new Character("me");
+
+      AMateria* tmp;
+      tmp = src->createMateria("ice");
+      me->equip(tmp);
+      tmp = src->createMateria("cure");
+      me->equip(tmp);
+
+      ICharacter* bob = new Character("bob");
+
+      me->use(0, *bob);
+      me->use(1, *bob);
+
+      delete bob;
+      delete me;
+      delete src;
+
+      return 0;
+}
+
+  Devrait afficher :
+
+$> clang++ -W -Wall -Werror *.cpp
+$> ./a.out | cat -e
+* shoots an ice bolt at bob *$
+* heals bob's wounds *$
+
+  Comme d’habitude, écrivez et rendez plus de tests que ceux donnés ci-dessus.
+
+Vous pouvez valider ce module sans l’exercice 03.
+
+                                                  13
+Chapitre VII
+Submission and peer-evaluation
+
+    Rendez votre travail dans votre dépôt Git comme d’habitude. Seul le travail présent
+sur votre dépôt sera évalué en soutenance. Vérifiez bien les noms de vos dossiers et de
+vos fichiers afin que ces derniers soient conformes aux demandes du sujet.
+
+                     ???????????? XXXXXXXXXX = $3$$6b616b91536363971573e58914295d42
+
+                                                       14
+

+ 357 - 0
Module_05/en.subject.pdf

@@ -0,0 +1,357 @@
+            C++ - Module 05
+
+           Repetition and Exceptions
+
+                                         Summary:
+This document contains the exercises of Module 05 from the C++ modules.
+
+                                       Version: 10.3
+Contents
+
+I   Introduction                                    2
+
+II  General rules                                   3
+
+III Exercise 00: Mommy, when I grow up, I want to be a bureaucrat! 6
+
+IV Exercise 01: Form up, maggots!                   8
+
+V   Exercise 02: No, you need form 28B, not 28C...  10
+
+VI Exercise 03: At least this beats coffee-making   12
+
+VII Submission and Peer Evaluation                  14
+
+                   1
+Chapter I
+Introduction
+
+C++ is a general-purpose programming language created by Bjarne Stroustrup as an ex-
+tension of the C programming language, or "C with Classes" (source: Wikipedia).
+
+    The goal of these modules is to introduce you to Object-Oriented Programming.
+This will be the starting point of your C++ journey. Many languages are recommended
+for learning OOP. We have chosen C++ since it is derived from your old friend, C.
+Because this is a complex language, and in order to keep things simple, your code will
+comply with the C++98 standard.
+
+    We are aware that modern C++ is significantly different in many aspects. So, if you
+want to become a proficient C++ developer, it is up to you to go further after the 42
+Common Core!
+
+                                                        2
+Chapter II
+
+General rules
+
+Compiling
+
+    • Compile your code with c++ and the flags -Wall -Wextra -Werror
+    • Your code should still compile if you add the flag -std=c++98
+
+    Formatting and naming conventions
+
+    • The exercise directories will be named this way: ex00, ex01, ... , exn
+    • Name your files, classes, functions, member functions and attributes as required in
+
+       the guidelines.
+    • Write class names in UpperCamelCase format. Files containing class code will
+
+       always be named according to the class name. For instance:
+       ClassName.hpp/ClassName.h, ClassName.cpp, or ClassName.tpp. Then, if you
+       have a header file containing the definition of a class "BrickWall" standing for a
+       brick wall, its name will be BrickWall.hpp.
+    • Unless specified otherwise, every output message must end with a newline character
+       and be displayed to the standard output.
+    • Goodbye Norminette! No coding style is enforced in the C++ modules. You can
+       follow your favorite one. But keep in mind that code your peer evaluators can’t
+       understand is code they can’t grade. Do your best to write clean and readable code.
+
+    Allowed/Forbidden
+
+    You are not coding in C anymore. Time to C++! Therefore:
+
+    • You are allowed to use almost everything from the standard library. Thus, instead
+       of sticking to what you already know, it would be smart to use the C++-ish versions
+       of the C functions you are used to as much as possible.
+
+    • However, you can’t use any other external library. It means C++11 (and derived
+       forms) and Boost libraries are forbidden. The following functions are forbidden
+       too: *printf(), *alloc() and free(). If you use them, your grade will be 0 and
+       that’s it.
+
+                                                        3
+C++ - Module 05  Repetition and Exceptions
+
+• Note that unless explicitly stated otherwise, the using namespace <ns_name> and
+  friend keywords are forbidden. Otherwise, your grade will be -42.
+
+• You are allowed to use the STL only in Modules 08 and 09. That means:
+  no Containers (vector/list/map, and so forth) and no Algorithms (anything that
+  requires including the <algorithm> header) until then. Otherwise, your grade will
+  be -42.
+
+A few design requirements
+
+• Memory leakage occurs in C++ too. When you allocate memory (by using the new
+  keyword), you must avoid memory leaks.
+
+• From Module 02 to Module 09, your classes must be designed in the Orthodox
+  Canonical Form, except when explicitly stated otherwise.
+
+• Any function implementation put in a header file (except for function templates)
+  means 0 to the exercise.
+
+• You should be able to use each of your headers independently from others. Thus,
+  they must include all the dependencies they need. However, you must avoid the
+  problem of double inclusion by adding include guards. Otherwise, your grade will
+  be 0.
+
+Read me
+
+• You can add some additional files if you need to (i.e., to split your code). As these
+  assignments are not verified by a program, feel free to do so as long as you turn in
+  the mandatory files.
+
+• Sometimes, the guidelines of an exercise look short but the examples can show
+  requirements that are not explicitly written in the instructions.
+
+• Read each module completely before starting! Really, do it.
+
+• By Odin, by Thor! Use your brain!!!
+
+Regarding the Makefile for C++ projects, the same rules as in C apply
+(see the Norm chapter about the Makefile).
+
+You will have to implement a lot of classes. This can seem tedious,
+unless you’re able to script your favorite text editor.
+
+                                      4
+C++ - Module 05     Repetition and Exceptions
+
+You are given a certain amount of freedom to complete the exercises.
+However, follow the mandatory rules and don’t be lazy. You would
+miss a lot of useful information! Do not hesitate to read about
+theoretical concepts.
+
+                 5
+Chapter III
+
+Exercise 00: Mommy, when I grow
+up, I want to be a bureaucrat!
+
+                                                   Exercise : 00
+                            Mommy, when I grow up, I want to be a bureaucrat!
+    Turn-in directory : ex00/
+    Files to turn in : Makefile, main.cpp, Bureaucrat.{h, hpp}, Bureaucrat.cpp
+    Forbidden functions : None
+
+                     Please note that exception classes do not have to be designed in
+                     Orthodox Canonical Form. However, every other class must follow it.
+
+    Let’s design an artificial nightmare of offices, corridors, forms, and waiting queues.
+Sounds fun? No? Too bad.
+
+    First, start with the smallest cog in this vast bureaucratic machine: the Bureaucrat.
+    A Bureaucrat must have:
+    • A constant name.
+    • A grade that ranges from 1 (highest possible grade) to 150 (lowest possible grade).
+    Any attempt to instantiate a Bureaucrat with an invalid grade must throw an excep-
+tion:
+either a Bureaucrat::GradeTooHighException or a Bureaucrat::GradeTooLowException.
+
+                                                        6
+C++ - Module 05     Repetition and Exceptions
+
+    You will provide getters for both attributes: getName() and getGrade(). You must
+also implement two member functions to increment or decrement the bureaucrat’s grade.
+If the grade goes out of range, both functions must throw the same exceptions as the
+constructor.
+
+                     Remember, since grade 1 is the highest and 150 the lowest,
+                     incrementing a grade 3 should result in a grade 2 for the bureaucrat.
+
+    The thrown exceptions must be catchable using try and catch blocks:
+
+ try
+ {
+
+       /* do some stuff with bureaucrats */
+ }
+ catch (std::exception & e)
+ {
+
+       /* handle exception */
+ }
+
+    You must implement an overload of the insertion («) operator to print output in the
+following format (without the angle brackets):
+
+    <name>, bureaucrat grade <grade>.
+
+    As usual, submit some tests to prove that everything works as expected.
+
+                 7
+Chapter IV
+
+Exercise 01: Form up, maggots!
+
+                                                   Exercise : 01
+                                                   Form up, maggots!
+    Turn-in directory : ex01/
+    Files to turn in : Files from the previous exercise + Form.{h, hpp}, Form.cpp
+    Forbidden functions : None
+
+    Now that you have bureaucrats, let’s give them something to do. What better activity
+could there be than filling out a stack of forms?
+
+    Let’s create a Form class. It has:
+    • A constant name.
+    • A boolean indicating whether it is signed (at construction, it is not).
+    • A constant grade required to sign it.
+    • A constant grade required to execute it.
+    All these attributes are private, not protected.
+    The grades of the Form follow the same rules as those of the Bureaucrat. Thus, the
+following exceptions will be thrown if a form’s grade is out of bounds:
+Form::GradeTooHighException and Form::GradeTooLowException.
+    As before, write getters for all attributes and overload the insertion («) operator to
+print all the form’s information.
+
+                                                        8
+C++ - Module 05     Repetition and Exceptions
+
+    Also, add a beSigned() member function to the Form that takes a Bureaucrat as a
+parameter. It changes the form’s status to signed if the bureaucrat’s grade is high enough
+(greater than or equal to the required one). Remember, grade 1 is higher than grade 2.
+If the grade is too low, throw a Form::GradeTooLowException.
+
+    Then, modify the signForm() member function in the Bureaucrat class. This func-
+tion must call Form::beSigned() to attempt to sign the form. If the form is signed
+successfully, it will print something like:
+
+    <bureaucrat> signed <form>
+
+    Otherwise, it will print something like:
+
+    <bureaucrat> couldn’t sign <form> because <reason>.
+
+    Implement and submit some tests to ensure everything works as expected.
+
+                 9
+Chapter V
+
+Exercise 02: No, you need form 28B,
+not 28C...
+
+                                                   Exercise : 02
+
+                                        No, you need form 28B, not 28C...
+    Turn-in directory : ex02/
+    Files to turn in : Makefile, main.cpp, Bureaucrat.[{h, hpp},cpp], +
+    AForm.[{h, hpp},cpp], ShrubberyCreationForm.[{h, hpp},cpp], +
+    RobotomyRequestForm.[{h, hpp},cpp], PresidentialPardonForm.[{h, hpp},cpp]
+    Forbidden functions : None
+
+    Now that you have basic forms, it’s time to create a few more that actually do some-
+thing.
+
+    In all cases, the base class Form must be an abstract class and should therefore be
+renamed AForm. Keep in mind that the form’s attributes need to remain private and
+that they belong to the base class.
+
+    Add the following concrete classes:
+
+    • ShrubberyCreationForm: Required grades: sign 145, exec 137
+       Creates a file <target>_shrubbery in the working directory and writes ASCII trees
+       inside it.
+
+    • RobotomyRequestForm: Required grades: sign 72, exec 45
+       Makes some drilling noises, then informs that <target> has been robotomized
+       successfully 50% of the time. Otherwise, it informs that the robotomy failed.
+
+    • PresidentialPardonForm: Required grades: sign 25, exec 5
+       Informs that <target> has been pardoned by Zaphod Beeblebrox.
+
+    All of them take only one parameter in their constructor: the target of the form. For
+example, "home" if you want to plant shrubbery at home.
+
+                                                       10
+C++ - Module 05      Repetition and Exceptions
+
+    Now, add the execute(Bureaucrat const & executor) const member function to
+the base form and implement a function to execute the form’s action in the concrete
+classes. You must check that the form is signed and that the grade of the bureaucrat at-
+tempting to execute the form is high enough. Otherwise, throw an appropriate exception.
+
+    Whether you check the requirements in every concrete class or in the base class (and
+then call another function to execute the form) is up to you. However, one way is more
+elegant than the other.
+
+    Lastly, add the executeForm(AForm const & form) const member function to the
+Bureaucrat class. It must attempt to execute the form. If successful, print something like:
+
+    <bureaucrat> executed <form>
+
+    If not, print an explicit error message.
+
+    Implement and submit some tests to ensure everything works as expected.
+
+                 11
+Chapter VI
+
+Exercise 03: At least this beats
+coffee-making
+
+                                                   Exercise : 03
+                                         At least this beats coffee-making
+    Turn-in directory : ex03/
+    Files to turn in : Files from previous exercises + Intern.{h, hpp}, Intern.cpp
+    Forbidden functions : None
+
+    Since filling out forms all day would be too cruel for our bureaucrats, interns exist to
+take on this tedious task. In this exercise, you must implement the Intern class. The
+intern has no name, no grade, and no unique characteristics. The only thing bureaucrats
+care about is that they do their job.
+
+    However, the intern has one key ability: the makeForm() function. This function
+takes two strings as parameters: the first one represents the name of a form, and the
+second one represents the target of the form. It returns a pointer to a AForm object
+(corresponding to the form name passed as a parameter), with its target initialized to
+the second parameter.
+
+    It should print something like:
+    Intern creates <form>
+    If the provided form name does not exist, print an explicit error message.
+
+                                                       12
+C++ - Module 05                                                       Repetition and Exceptions
+
+    You must avoid unreadable and messy solutions, such as using an excessive if/el-
+seif/else structure. This kind of approach will not be accepted during the evaluation
+process. You’re not in the Piscine (pool) anymore. As usual, you must test everything
+to ensure it works as expected.
+
+    For example, the following code creates a RobotomyRequestForm targeted at
+"Bender":
+
+{
+      Intern someRandomIntern;
+      AForm* rrf;
+
+      rrf = someRandomIntern.makeForm("robotomy request", "Bender");
+}
+
+                 13
+Chapter VII
+Submission and Peer Evaluation
+
+Submit your assignment to your Git repository as usual. Only the work inside your
+repository will be evaluated during the defense. Make sure to double-check the names of
+your folders and files to ensure they are correct.
+
+                     16D85ACC441674FBA2DF65190663F9373230CEAB1E4A0818611C0E39F5B26E4D774F1
+                     74620A16827E1B16612137E59ECD492E468A92DCB17BF16988114B98587594D12810
+                     E67D173222A
+
+                                                       14
+

+ 285 - 0
Module_06/en.subject.pdf

@@ -0,0 +1,285 @@
+               C++ - Module 06
+
+                        C++ casts
+
+Summary: This document contains the exercises for Module 06 of the C++ modules.
+                                              Version: 7.2
+Contents
+
+I   Introduction                            2
+
+II  General rules                           3
+
+III Additional Rule                         6
+
+IV Exercise 00: Conversion of scalar types  7
+
+V   Exercise 01: Serialization              10
+
+VI Exercise 02: Identify real type          11
+
+VII Submission and Peer Evaluation          12
+
+                                    1
+Chapter I
+Introduction
+
+C++ is a general-purpose programming language created by Bjarne Stroustrup as an ex-
+tension of the C programming language, often referred to as "C with Classes" (source:
+Wikipedia).
+
+    The goal of these modules is to introduce you to Object-Oriented Programming.
+This will be the starting point of your C++ journey. Many languages are recommended
+for learning OOP, but we chose C++ since it is derived from your old friend, C. As C++
+is a complex language, your code will adhere to the C++98 standard to keep things
+simple.
+
+    We acknowledge that modern C++ differs significantly in many aspects. If you want
+to become a proficient C++ developer, it will be up to you to explore further beyond the
+42 Common Core!
+
+                                                        2
+Chapter II
+
+General rules
+
+Compiling
+
+    • Compile your code with c++ and the flags -Wall -Wextra -Werror
+    • Your code should still compile if you add the flag -std=c++98
+
+    Formatting and naming conventions
+
+    • The exercise directories will be named this way: ex00, ex01, ... , exn
+    • Name your files, classes, functions, member functions and attributes as required in
+
+       the guidelines.
+    • Write class names in UpperCamelCase format. Files containing class code will
+
+       always be named according to the class name. For instance:
+       ClassName.hpp/ClassName.h, ClassName.cpp, or ClassName.tpp. Then, if you
+       have a header file containing the definition of a class "BrickWall" standing for a
+       brick wall, its name will be BrickWall.hpp.
+    • Unless specified otherwise, every output message must end with a newline character
+       and be displayed to the standard output.
+    • Goodbye Norminette! No coding style is enforced in the C++ modules. You can
+       follow your favorite one. But keep in mind that code your peer evaluators can’t
+       understand is code they can’t grade. Do your best to write clean and readable code.
+
+    Allowed/Forbidden
+
+    You are not coding in C anymore. Time to C++! Therefore:
+
+    • You are allowed to use almost everything from the standard library. Thus, instead
+       of sticking to what you already know, it would be smart to use the C++-ish versions
+       of the C functions you are used to as much as possible.
+
+    • However, you can’t use any other external library. It means C++11 (and derived
+       forms) and Boost libraries are forbidden. The following functions are forbidden
+       too: *printf(), *alloc() and free(). If you use them, your grade will be 0 and
+       that’s it.
+
+                                                        3
+C++ - Module 06  C++ casts
+
+• Note that unless explicitly stated otherwise, the using namespace <ns_name> and
+  friend keywords are forbidden. Otherwise, your grade will be -42.
+
+• You are allowed to use the STL only in Modules 08 and 09. That means:
+  no Containers (vector/list/map, and so forth) and no Algorithms (anything that
+  requires including the <algorithm> header) until then. Otherwise, your grade will
+  be -42.
+
+A few design requirements
+
+• Memory leakage occurs in C++ too. When you allocate memory (by using the new
+  keyword), you must avoid memory leaks.
+
+• From Module 02 to Module 09, your classes must be designed in the Orthodox
+  Canonical Form, except when explicitly stated otherwise.
+
+• Any function implementation put in a header file (except for function templates)
+  means 0 to the exercise.
+
+• You should be able to use each of your headers independently from others. Thus,
+  they must include all the dependencies they need. However, you must avoid the
+  problem of double inclusion by adding include guards. Otherwise, your grade will
+  be 0.
+
+Read me
+
+• You can add some additional files if you need to (i.e., to split your code). As these
+  assignments are not verified by a program, feel free to do so as long as you turn in
+  the mandatory files.
+
+• Sometimes, the guidelines of an exercise look short but the examples can show
+  requirements that are not explicitly written in the instructions.
+
+• Read each module completely before starting! Really, do it.
+
+• By Odin, by Thor! Use your brain!!!
+
+Regarding the Makefile for C++ projects, the same rules as in C apply
+(see the Norm chapter about the Makefile).
+
+You will have to implement a lot of classes. This can seem tedious,
+unless you’re able to script your favorite text editor.
+
+                                      4
+C++ - Module 06     C++ casts
+
+You are given a certain amount of freedom to complete the exercises.
+However, follow the mandatory rules and don’t be lazy. You would
+miss a lot of useful information! Do not hesitate to read about
+theoretical concepts.
+
+                 5
+Chapter III
+Additional Rule
+
+The following rule applies to the entire module and is mandatory.
+    For each exercise, type conversion must be handled using a specific type of casting.
+
+Your choice will be reviewed during the defense.
+
+                                                        6
+Chapter IV
+
+Exercise 00: Conversion of scalar
+types
+
+                                                    Exercise 00
+                                              Conversion of scalar types
+    Turn-in directory: ex00/
+    Files to turn in: Makefile, *.cpp, *.{h, hpp}
+    Allowed functions: Any function to convert from a string to an int, a float,
+    or a double. This will help, but won’t do the whole job.
+
+    Write a class ScalarConverter that will contain only one static method "convert"
+that will take as a parameter a string representation of a C++ literal in its most common
+form and output its value in the following series of scalar types:
+
+    • char
+    • int
+    • float
+    • double
+As this class doesn’t need to store anything at all, it must not be instantiable by users.
+    Except for char parameters, only the decimal notation will be used.
+
+    Examples of char literals: ’c’, ’a’, ...
+To make things simple, please note that non-displayable characters shouldn’t be used as
+inputs. If a conversion to char is not displayable, print an informative message.
+
+    Examples of int literals: 0, -42, 42...
+
+    Examples of float literals: 0.0f, -4.2f, 4.2f...
+You have to handle these pseudo-literals as well (you know, for science): -inff, +inff,
+and nanf.
+
+                                                        7
+C++ - Module 06     C++ casts
+
+    Examples of double literals: 0.0, -4.2, 4.2...
+You have to handle these pseudo-literals as well (you know, for fun): -inf, +inf, and
+nan.
+
+                 8
+C++ - Module 06     C++ casts
+
+    Write a program to test that your class works as expected.
+
+    You have to first detect the type of the literal passed as a parameter, convert it from
+string to its actual type, then convert it explicitly to the three other data types. Lastly,
+display the results as shown below.
+
+    If a conversion does not make any sense or overflows, display a message to inform
+the user that the type conversion is impossible. Include any header you need in order to
+handle numeric limits and special values.
+
+     ./convert 0
+     char: Non displayable
+     int: 0
+     float: 0.0f
+     double: 0.0
+     ./convert nan
+     char: impossible
+     int: impossible
+     float: nanf
+     double: nan
+     ./convert 42.0f
+     char: '*'
+     int: 42
+     float: 42.0f
+     double: 42.0
+
+                 9
+Chapter V
+
+Exercise 01: Serialization
+
+                                                   Exercise : 01
+                                                       Serialization
+
+    Turn-in directory: ex01/
+    Files to turn in: Makefile, *.cpp, *.{h, hpp}
+    Forbidden functions: None
+
+    Implement a class Serializer, which will not be initializable by the user in any way,
+with the following static methods:
+
+    uintptr_t serialize(Data* ptr);
+It takes a pointer and converts it to the unsigned integer type uintptr_t.
+
+    Data* deserialize(uintptr_t raw);
+It takes an unsigned integer parameter and converts it to a pointer to Data.
+
+    Write a program to test that your class works as expected.
+    You must create a non-empty (meaning it has data members) Data structure.
+    Use serialize() on the address of the Data object and pass its return value to
+deserialize(). Then, ensure the return value of deserialize() compares equal to the
+original pointer.
+    Do not forget to turn in the files of your Data structure.
+
+                                                       10
+Chapter VI
+
+Exercise 02: Identify real type
+
+                                                   Exercise : 02
+                                                    Identify real type
+    Turn-in directory: ex02/
+    Files to turn in: Makefile, *.cpp, *.{h, hpp}
+    Forbidden functions: std::typeinfo
+
+    Implement a Base class that has a public virtual destructor only. Create three empty
+classes A, B, and C, that publicly inherit from Base.
+
+                     These four classes don’t have to be designed in the Orthodox
+                     Canonical Form.
+
+    Implement the following functions:
+    Base * generate(void);
+It randomly instantiates A, B, or C and returns the instance as a Base pointer. Feel free
+to use anything you like for the random choice implementation.
+    void identify(Base* p);
+It prints the actual type of the object pointed to by p: "A", "B", or "C".
+    void identify(Base& p);
+It prints the actual type of the object referenced by p: "A", "B", or "C". Using a pointer
+inside this function is forbidden.
+    Including the typeinfo header is forbidden.
+    Write a program to test that everything works as expected.
+
+                                                       11
+Chapter VII
+Submission and Peer Evaluation
+
+Submit your assignment to your Git repository as usual. Only the work inside your
+repository will be evaluated during the defense. Don’t hesitate to double-check the names
+of your folders and files to ensure they are correct.
+
+                     16D85ACC441674FBA2DF65190663E136253996A5020347143B460E2CF3A3784D794B
+                     104265933C3BE5B62C4E062601EC8DD1F82FEB73CB17AC57D49054A7C29B5A5C1D8
+                     2027A997A3E24E387
+
+                                                       12
+

+ 264 - 0
Module_07/en.subject.pdf

@@ -0,0 +1,264 @@
+           C++ - Module 07
+
+                C++ templates
+
+                                       Summary:
+This document contains the exercises of Module 07 from C++ modules.
+
+                                      Version: 9.3
+Contents
+
+I   Introduction                             2
+
+II  General rules                            3
+
+III Exercise 00: Start with a few functions  5
+
+IV Exercise 01: Iter                         7
+
+V   Exercise 02: Array                       8
+
+VI Submission and peer-evaluation            9
+
+                        1
+Chapter I
+Introduction
+
+C++ is a general-purpose programming language created by Bjarne Stroustrup as an ex-
+tension of the C programming language, or "C with Classes" (source: Wikipedia).
+
+    The goal of these modules is to introduce you to Object-Oriented Programming.
+This will be the starting point of your C++ journey. Many languages are recommended
+to learn OOP. We decided to choose C++ since it’s derived from your old friend C.
+Because this is a complex language, and in order to keep things simple, your code will
+comply with the C++98 standard.
+
+    We are aware modern C++ is way different in a lot of aspects. So if you want to
+become a proficient C++ developer, it’s up to you to go further after the 42 Common
+Core!
+
+                                                        2
+Chapter II
+
+General rules
+
+Compiling
+
+    • Compile your code with c++ and the flags -Wall -Wextra -Werror
+    • Your code should still compile if you add the flag -std=c++98
+
+    Formatting and naming conventions
+
+    • The exercise directories will be named this way: ex00, ex01, ... , exn
+    • Name your files, classes, functions, member functions and attributes as required in
+
+       the guidelines.
+
+    • Write class names in UpperCamelCase format. Files containing class code will
+       always be named according to the class name. For instance:
+       ClassName.hpp/ClassName.h, ClassName.cpp, or ClassName.tpp. Then, if you
+       have a header file containing the definition of a class "BrickWall" standing for a
+       brick wall, its name will be BrickWall.hpp.
+
+    • Unless specified otherwise, every output messages must be ended by a new-line
+       character and displayed to the standard output.
+
+    • Goodbye Norminette! No coding style is enforced in the C++ modules. You can
+       follow your favorite one. But keep in mind that a code your peer-evaluators can’t
+       understand is a code they can’t grade. Do your best to write a clean and readable
+       code.
+
+    Allowed/Forbidden
+
+    You are not coding in C anymore. Time to C++! Therefore:
+
+    • You are allowed to use almost everything from the standard library. Thus, instead
+       of sticking to what you already know, it would be smart to use as much as possible
+       the C++-ish versions of the C functions you are used to.
+
+    • However, you can’t use any other external library. It means C++11 (and derived
+       forms) and Boost libraries are forbidden. The following functions are forbidden
+       too: *printf(), *alloc() and free(). If you use them, your grade will be 0 and
+       that’s it.
+
+                                                        3
+C++ - Module 07     C++ templates
+
+• Note that unless explicitly stated otherwise, the using namespace <ns_name> and
+  friend keywords are forbidden. Otherwise, your grade will be -42.
+
+• You are allowed to use the STL in the Module 08 and 09 only. That means:
+  no Containers (vector/list/map/and so forth) and no Algorithms (anything that
+  requires to include the <algorithm> header) until then. Otherwise, your grade will
+  be -42.
+
+A few design requirements
+
+• Memory leakage occurs in C++ too. When you allocate memory (by using the new
+  keyword), you must avoid memory leaks.
+
+• From Module 02 to Module 09, your classes must be designed in the Orthodox
+  Canonical Form, except when explicitely stated otherwise.
+
+• Any function implementation put in a header file (except for function templates)
+  means 0 to the exercise.
+
+• You should be able to use each of your headers independently from others. Thus,
+  they must include all the dependencies they need. However, you must avoid the
+  problem of double inclusion by adding include guards. Otherwise, your grade will
+  be 0.
+
+Read me
+
+• You can add some additional files if you need to (i.e., to split your code). As these
+  assignments are not verified by a program, feel free to do so as long as you turn in
+  the mandatory files.
+
+• Sometimes, the guidelines of an exercise look short but the examples can show
+  requirements that are not explicitly written in the instructions.
+
+• Read each module completely before starting! Really, do it.
+
+• By Odin, by Thor! Use your brain!!!
+
+You will have to implement a lot of classes. This can seem tedious,
+unless you’re able to script your favorite text editor.
+
+You are given a certain amount of freedom to complete the exercises.
+However, follow the mandatory rules and don’t be lazy. You would
+miss a lot of useful information! Do not hesitate to read about
+theoretical concepts.
+
+                 4
+Chapter III
+Exercise 00: Start with a few
+functions
+
+                                                   Exercise : 00
+                                              Start with a few functions
+    Turn-in directory : ex00/
+    Files to turn in : Makefile, main.cpp, whatever.{h, hpp}
+    Forbidden functions : None
+
+    Implement the following function templates:
+    • swap: Swaps the values of two given parameters. Does not return anything.
+    • min: Compares the two values passed as parameters and returns the smallest one.
+
+       If they are equal, it returns the second one.
+    • max: Compares the two values passed as parameters and returns the greatest one.
+
+       If they are equal, it returns the second one.
+    These functions can be called with any type of argument. The only requirement is
+that the two arguments must have the same type and must support all the comparison
+operators.
+
+                     Templates must be defined in the header files.
+
+                                                        5
+C++ - Module 07                                                    C++ templates
+
+Running the following code:
+
+int  main( void ) {
+
+     int a = 2;
+     int b = 3;
+
+     ::swap( a, b );
+     std::cout << "a = " << a << ", b = " << b << std::endl;
+     std::cout << "min( a, b ) = " << ::min( a, b ) << std::endl;
+     std::cout << "max( a, b ) = " << ::max( a, b ) << std::endl;
+
+     std::string c = "chaine1";
+     std::string d = "chaine2";
+
+     ::swap(c, d);
+     std::cout << "c = " << c << ", d = " << d << std::endl;
+     std::cout << "min( c, d ) = " << ::min( c, d ) << std::endl;
+     std::cout << "max( c, d ) = " << ::max( c, d ) << std::endl;
+
+      return 0;
+}
+
+Should output:
+
+a = 3, b = 2
+min(a, b) = 2
+max(a, b) = 3
+c = chaine2, d = chaine1
+min(c, d) = chaine1
+max(c, d) = chaine2
+
+                                 6
+Chapter IV
+Exercise 01: Iter
+
+                                                   Exercise : 01
+                                                             Iter
+
+    Turn-in directory : ex01/
+    Files to turn in : Makefile, main.cpp, iter.{h, hpp}
+    Forbidden functions : None
+
+    Implement a function template iter that takes 3 parameters and returns nothing.
+    • The first parameter is the address of an array.
+    • The second one is the length of the array.
+    • The third one is a function that will be called on every element of the array.
+    Submit a main.cpp file that contains your tests. Provide enough code to generate a
+test executable.
+    Your iter function template must work with any type of array. The third parameter
+can be an instantiated function template.
+    The function passed as the third parameter may take its argument by const reference
+or non-const reference, depending on the context.
+
+                     Think carefully about how to support both const and non-const
+                     elements in your iter function.
+
+                                                        7
+Chapter V
+
+Exercise 02: Array
+
+                                                   Exercise : 02
+
+                                                           Array
+    Turn-in directory : ex02/
+    Files to turn in : Makefile, main.cpp, Array.{h, hpp}
+    and optional file: Array.tpp
+    Forbidden functions : None
+
+    Develop a class template Array that contains elements of type T and that implements
+the following behavior and functions:
+
+    • Construction with no parameter: Creates an empty array.
+    • Construction with an unsigned int n as a parameter: Creates an array of n elements
+
+       initialized by default.
+       Tip: Try to compile int * a = new int(); then display *a.
+    • Construction by copy and assignment operator. In both cases, modifying either the
+       original array or its copy after copying musn’t affect the other array.
+    • You MUST use the operator new[] to allocate memory. Preventive allocation (al-
+       locating memory in advance) is forbidden. Your program must never access non-
+       allocated memory.
+    • Elements can be accessed through the subscript operator: [ ].
+    • When accessing an element with the [ ] operator, if its index is out of bounds, an
+       std::exception is thrown.
+    • A member function size() that returns the number of elements in the array. This
+       member function takes no parameters and must not modify the current instance.
+    As usual, ensure everything works as expected and turn in a main.cpp file that con-
+tains your tests.
+
+                                                        8
+Chapter VI
+Submission and peer-evaluation
+
+Turn in your assignment in your Git repository as usual. Only the work inside your
+repository will be evaluated during the defense. Don’t hesitate to double check the
+names of your folders and files to ensure they are correct.
+
+                     16D85ACC441674FBA2DF65190663F43A243E8FA5424E49143B520D3DF8AF68036E47
+                     114F20A16827E1B16612137E59ECD492E468BC6CD109F65388DC57A58E8942585C8
+                     D193B96732206
+
+                                                        9
+

+ 53 - 0
Module_07/main.cpp

@@ -0,0 +1,53 @@
+#include <iostream>
+#include <Array.hpp>
+
+#define MAX_VAL 750
+int main(int, char**)
+{
+    Array<int> numbers(MAX_VAL);
+    int* mirror = new int[MAX_VAL];
+    srand(time(NULL));
+    for (int i = 0; i < MAX_VAL; i++)
+    {
+        const int value = rand();
+        numbers[i] = value;
+        mirror[i] = value;
+    }
+    //SCOPE
+    {
+        Array<int> tmp = numbers;
+        Array<int> test(tmp);
+    }
+
+    for (int i = 0; i < MAX_VAL; i++)
+    {
+        if (mirror[i] != numbers[i])
+        {
+            std::cerr << "didn't save the same value!!" << std::endl;
+            return 1;
+        }
+    }
+    try
+    {
+        numbers[-2] = 0;
+    }
+    catch(const std::exception& e)
+    {
+        std::cerr << e.what() << '\n';
+    }
+    try
+    {
+        numbers[MAX_VAL] = 0;
+    }
+    catch(const std::exception& e)
+    {
+        std::cerr << e.what() << '\n';
+    }
+
+    for (int i = 0; i < MAX_VAL; i++)
+    {
+        numbers[i] = rand();
+    }
+    delete [] mirror;//
+    return 0;
+}

+ 322 - 0
Module_08/en.subject.pdf

@@ -0,0 +1,322 @@
+           C++ - Module 08
+
+Templated containers, iterators, algorithms
+
+                                       Summary:
+This document contains the exercises of Module 08 from C++ modules.
+
+                                      Version: 8.1
+Contents
+
+I   Introduction                     2
+
+II  General rules                    3
+
+III Module-specific rules            6
+
+IV Exercise 00: Easy find            7
+
+V   Exercise 01: Span                8
+
+VI Exercise 02: Mutated abomination  10
+
+VII Submission and peer-evaluation   12
+
+                           1
+Chapter I
+Introduction
+
+C++ is a general-purpose programming language created by Bjarne Stroustrup as an ex-
+tension of the C programming language, or "C with Classes" (source: Wikipedia).
+
+    The goal of these modules is to introduce you to Object-Oriented Programming.
+This will be the starting point of your C++ journey. Many languages are recommended
+to learn OOP. We decided to choose C++ since it’s derived from your old friend C.
+Because this is a complex language, and in order to keep things simple, your code will
+comply with the C++98 standard.
+
+    We are aware modern C++ is way different in a lot of aspects. So if you want to
+become a proficient C++ developer, it’s up to you to go further after the 42 Common
+Core!
+
+                                                        2
+Chapter II
+
+General rules
+
+Compiling
+
+    • Compile your code with c++ and the flags -Wall -Wextra -Werror
+    • Your code should still compile if you add the flag -std=c++98
+
+    Formatting and naming conventions
+
+    • The exercise directories will be named this way: ex00, ex01, ... , exn
+    • Name your files, classes, functions, member functions and attributes as required in
+
+       the guidelines.
+    • Write class names in UpperCamelCase format. Files containing class code will
+
+       always be named according to the class name. For instance:
+       ClassName.hpp/ClassName.h, ClassName.cpp, or ClassName.tpp. Then, if you
+       have a header file containing the definition of a class "BrickWall" standing for a
+       brick wall, its name will be BrickWall.hpp.
+    • Unless specified otherwise, every output message must end with a newline character
+       and be displayed to the standard output.
+    • Goodbye Norminette! No coding style is enforced in the C++ modules. You can
+       follow your favorite one. But keep in mind that code your peer evaluators can’t
+       understand is code they can’t grade. Do your best to write clean and readable code.
+
+    Allowed/Forbidden
+
+    You are not coding in C anymore. Time to C++! Therefore:
+
+    • You are allowed to use almost everything from the standard library. Thus, instead
+       of sticking to what you already know, it would be smart to use the C++-ish versions
+       of the C functions you are used to as much as possible.
+
+    • However, you can’t use any other external library. It means C++11 (and derived
+       forms) and Boost libraries are forbidden. The following functions are forbidden
+       too: *printf(), *alloc() and free(). If you use them, your grade will be 0 and
+       that’s it.
+
+                                                        3
+C++ - Module 08  Templated containers, iterators, algorithms
+
+• Note that unless explicitly stated otherwise, the using namespace <ns_name> and
+  friend keywords are forbidden. Otherwise, your grade will be -42.
+
+• You are allowed to use the STL only in Modules 08 and 09. That means:
+  no Containers (vector/list/map, and so forth) and no Algorithms (anything that
+  requires including the <algorithm> header) until then. Otherwise, your grade will
+  be -42.
+
+A few design requirements
+
+• Memory leakage occurs in C++ too. When you allocate memory (by using the new
+  keyword), you must avoid memory leaks.
+
+• From Module 02 to Module 09, your classes must be designed in the Orthodox
+  Canonical Form, except when explicitly stated otherwise.
+
+• Any function implementation put in a header file (except for function templates)
+  means 0 to the exercise.
+
+• You should be able to use each of your headers independently from others. Thus,
+  they must include all the dependencies they need. However, you must avoid the
+  problem of double inclusion by adding include guards. Otherwise, your grade will
+  be 0.
+
+Read me
+
+• You can add some additional files if you need to (i.e., to split your code). As these
+  assignments are not verified by a program, feel free to do so as long as you turn in
+  the mandatory files.
+
+• Sometimes, the guidelines of an exercise look short but the examples can show
+  requirements that are not explicitly written in the instructions.
+
+• Read each module completely before starting! Really, do it.
+
+• By Odin, by Thor! Use your brain!!!
+
+Regarding the Makefile for C++ projects, the same rules as in C apply
+(see the Norm chapter about the Makefile).
+
+You will have to implement a lot of classes. This can seem tedious,
+unless you’re able to script your favorite text editor.
+
+                                      4
+C++ - Module 08  Templated containers, iterators, algorithms
+
+You are given a certain amount of freedom to complete the exercises.
+However, follow the mandatory rules and don’t be lazy. You would
+miss a lot of useful information! Do not hesitate to read about
+theoretical concepts.
+
+                 5
+Chapter III
+Module-specific rules
+
+You will notice that, in this module, the exercises can be solved WITHOUT the standard
+Containers and WITHOUT the standard Algorithms.
+
+    However, using them is precisely the goal of this Module.
+You must use the STL — especially the Containers (vector/list/map/and so forth)
+and the Algorithms (defined in header <algorithm>) — whenever they are appropriate.
+Moreover, you should use them as much as you can.
+Thus, do your best to apply them wherever it’s appropriate.
+
+    You will get a very bad grade if you don’t, even if your code works as expected. Please
+don’t be lazy.
+
+    You can define your templates in the header files as usual. Or, if you want to, you
+can write your template declarations in the header files and write their implementations
+in .tpp files. In any case, the header files are mandatory while the .tpp files are optional.
+
+                                                        6
+Chapter IV
+Exercise 00: Easy find
+
+                                                   Exercise : 00
+                                                         Easy find
+
+    Turn-in directory: ex00/
+    Files to turn in: Makefile, main.cpp, easyfind.{h, hpp}
+    and optional file: easyfind.tpp
+    Forbidden functions: None
+
+    A first easy exercise is the way to start off on the right foot.
+    Write a function template easyfind that accepts a type T. It takes two parameters:
+the first one is of type T, and the second one is an integer.
+    Assuming T is a container of integers, this function has to find the first occurrence
+of the second parameter in the first parameter.
+    If no occurrence is found, you can either throw an exception or return an error value
+of your choice. If you need some inspiration, analyze how standard containers behave.
+    Of course, implement and turn in your own tests to ensure everything works as ex-
+pected.
+
+                     You don’t have to handle associative containers.
+
+                                                        7
+Chapter V
+Exercise 01: Span
+
+                                                   Exercise : 01
+                                                            Span
+
+    Turn-in directory: ex01/
+    Files to turn in: Makefile, main.cpp, Span.{h, hpp}, Span.cpp
+    Forbidden functions: None
+
+    Develop a Span class that can store a maximum of N integers. N is an unsigned int
+variable and will be the only parameter passed to the constructor.
+
+    This class will have a member function called addNumber() to add a single number
+to the Span. It will be used in order to fill it. Any attempt to add a new element if there
+are already N elements stored should throw an exception.
+
+    Next, implement two member functions: shortestSpan() and longestSpan()
+    They will respectively find out the shortest span or the longest span (or distance, if
+you prefer) between all the numbers stored, and return it. If there are no numbers stored,
+or only one, no span can be found. Thus, throw an exception.
+    Of course, you will write your own tests, and they will be far more thorough than the
+ones below. Test your Span with at least 10,000 numbers. More would be even better.
+
+                                                        8
+C++ - Module 08                                  Templated containers, iterators, algorithms
+
+ Running this code:
+
+int main()
+{
+
+   Span sp = Span(5);
+
+   sp.addNumber(6);
+   sp.addNumber(3);
+   sp.addNumber(17);
+   sp.addNumber(9);
+   sp.addNumber(11);
+
+   std::cout << sp.shortestSpan() << std::endl;
+   std::cout << sp.longestSpan() << std::endl;
+
+   return 0;
+}
+
+  Should output:
+
+$> ./ex01
+2
+14
+$>
+
+    Last but not least, it would be wonderful to fill your Span using a range of iterators.
+Making thousands of calls to addNumber() is so annoying. Implement a member function
+to add multiple numbers to your Span in a single call.
+
+If you don’t have a clue, study the Containers. Some member
+functions take a range of iterators in order to add a sequence of
+elements to the container.
+
+                                                 9
+Chapter VI
+Exercise 02: Mutated abomination
+
+                                                   Exercise : 02
+                                                 Mutated abomination
+    Turn-in directory: ex02/
+    Files to turn in: Makefile, main.cpp, MutantStack.{h, hpp}
+    and optional file: MutantStack.tpp
+    Forbidden functions: None
+
+    Now, it’s time to move on to more serious things. Let’s develop something weird.
+    The std::stack container is very nice. Unfortunately, it is one of the only STL Con-
+tainers that is NOT iterable. That’s too bad.
+    But why would we accept this? Especially if we can take the liberty of butchering the
+original stack to create missing features.
+    To repair this injustice, you have to make the std::stack container iterable.
+    Write a MutantStack class. It will be implemented in terms of a std::stack.
+It will offer all its member functions, plus an additional feature: iterators.
+    Of course, you will write and turn in your own tests to ensure everything works as
+expected.
+
+                                                       10
+C++ - Module 08                                  Templated containers, iterators, algorithms
+
+Find a test example below.
+
+int main()         mstack;
+{
+MutantStack<int>
+
+mstack.push(5);
+mstack.push(17);
+
+std::cout << mstack.top() << std::endl;
+
+mstack.pop();
+
+std::cout << mstack.size() << std::endl;
+
+mstack.push(3);
+mstack.push(5);
+mstack.push(737);
+//[...]
+mstack.push(0);
+
+MutantStack<int>::iterator it = mstack.begin();
+MutantStack<int>::iterator ite = mstack.end();
+
+++it;
+--it;
+while (it != ite)
+{
+
+      std::cout << *it << std::endl;
+      ++it;
+}
+std::stack<int> s(mstack);
+return 0;
+}
+
+    If you run it a first time with your MutantStack, and a second time replacing the
+MutantStack with, for example, a std::list, the two outputs should be the same. Of
+course, when testing another container, update the code below with the corresponding
+member functions (push() can become push_back()).
+
+                                                 11
+Chapter VII
+Submission and peer-evaluation
+
+Turn in your assignment in your Git repository as usual. Only the work inside your
+repository will be evaluated during the defense. Don’t hesitate to double check the
+names of your folders and files to ensure they are correct.
+
+                     16D85ACC441674FBA2DF65195A38EE36793A89EB04594B15725A1128E7E97B0E7B47
+                     111668BD6823E2F873124B7E59B5CE94B47AB764CF0AB316999C56E5989B4B4F00C
+                     91B619C70263F
+
+                                                       12
+

BIN
Module_09/cpp_09.tgz


+ 399 - 0
Module_09/fr.subject.pdf

@@ -0,0 +1,399 @@
+              C++ - Module 09
+
+                           STL
+
+Summary: Ce document contient les exercices du Module 09 de la Piscine C++.
+                                            Version: 2.1
+Contents
+
+I   Introduction                          2
+
+II  Consignes générales                   3
+
+III Règles spécifiques au module          6
+
+IV Exercice 00: Bitcoin Exchange          7
+
+V   Exercice 01: Reverse Polish Notation  9
+
+VI Exercice 02: PmergeMe                  11
+
+VII Rendu et évaluation                   14
+
+                                  1
+Chapter I
+Introduction
+
+C++ est un langage de programmation polyvalent créé par Bjarne Stroustrup en tant
+qu’extension du langage de programmation C, ou "C avec classes" (source: Wikipedia).
+
+    L’objectif de ces modules est de vous initier à ;a Programmation orientée-objet.
+Ce sera le point de départ de votre parcours en C++. De nombreux langages sont
+recommandés pour apprendre la POO. Nous avons choisi le C++ car il est dérivé de
+votre vieil ami, le C. Comme il s’agit d’un langage complexe, et afin de simplifier les
+choses, votre code sera conforme à la norme C++98.
+
+    Nous sommes conscients que le C++ moderne est très différent à bien des égards.
+Ainsi, si vous souhaitez devenir un développeur C++ compétent, il vous appartient d’aller
+plus loin après le Tronc Commun de 42!
+
+                                                        2
+Chapter II
+
+Consignes générales
+
+Compilation
+
+    • Compilez votre code avec c++ et les flags -Wall -Wextra -Werror
+    • Votre code doit compiler si vous ajoutez le flag -std=c++98
+
+    Format et conventions de nommage
+
+    • Les dossiers des exercices seront nommés ainsi : ex00, ex01, ... , exn
+    • Nommez vos fichiers, vos classes, vos fonctions, vos fonctions membres et vos at-
+
+       tributs comme spécifié dans les consignes.
+    • Rédigez vos noms de classe au format UpperCamelCase. Les fichiers contenant
+
+       le code d’une classe porteront le nom de cette dernière. Par exemple :
+       NomDeClasse.hpp/NomDeClasse.h, NomDeClasse.cpp, ou NomDeClasse.tpp.
+       Ainsi, si un fichier d’en-tête contient la définition d’une classe "BrickWall", son nom
+       sera BrickWall.hpp.
+    • Sauf si spécifié autrement, tous les messages doivent être terminés par un retour à
+       la ligne et être affichés sur la sortie standard.
+    • Ciao Norminette ! Aucune norme n’est imposée durant les modules C++. Vous
+       pouvez suivre le style de votre choix. Mais ayez à l’esprit qu’un code que vos pairs
+       ne peuvent comprendre est un code que vos pairs ne peuvent évaluer. Faites donc
+       de votre mieux pour produire un code propre et lisible.
+
+    Ce qui est autorisé et ce qui ne l’est pas
+    Le langage C, c’est fini pour l’instant. Voici l’heure de se mettre au C++ ! Par
+conséquent :
+
+                                                        3
+C++ - Module 09                       STL
+
+• Vous pouvez avoir recours à quasi l’ensemble de la bibliothèque standard. Donc
+  plutôt que de rester en terrain connu, essayez d’utiliser le plus possible les versions
+  C++ des fonctions C dont vous avec l’habitude.
+
+• Cependant, vous ne pouvez avoir recours à aucune autre bibliothèque externe. Ce
+  qui signifie que C++11 (et dérivés) et l’ensemble Boost sont interdits. Aussi, cer-
+  taines fonctions demeurent interdites. Utiliser les fonctions suivantes résultera en
+  la note de 0 : *printf(), *alloc() et free().
+
+• Sauf si explicitement indiqué autrement, les mots-clés using namespace <ns_name>
+  et friend sont interdits. Leur usage résultera en la note de -42.
+
+• Vous n’avez le droit à la STL que dans les Modules 08 et 09. D’ici là,
+  l’usage des Containers (vector/list/map/etc.) et des Algorithmes (tout ce qui
+  requiert d’inclure <algorithm>) est interdit. Dans le cas contraire, vous obtiendrez
+  la note de -42.
+
+Quelques obligations côté conception
+
+• Les fuites de mémoires existent aussi en C++. Quand vous allouez de la mémoire
+  (en utilisant le mot-clé new), vous ne devez pas avoir de memory leaks.
+
+• Du Module 02 au Module 09, vos classes devront se conformer à la forme canon-
+  ique, dite de Coplien, sauf si explicitement spécifié autrement.
+
+• Une fonction implémentée dans un fichier d’en-tête (hormis dans le cas de fonction
+  template) équivaudra à la note de 0.
+
+• Vous devez pouvoir utiliser vos fichiers d’en-tête séparément les uns des autres.
+  C’est pourquoi ils devront inclure toutes les dépendances qui leur seront nécessaires.
+  Cependant, vous devez éviter le problème de la double inclusion en les protégeant
+  avec des include guards. Dans le cas contraire, votre note sera de 0.
+
+Read me
+
+• Si vous en avez le besoin, vous pouvez rendre des fichiers supplémentaires (par
+  exemple pour séparer votre code en plus de fichiers). Vu que votre travail ne sera
+  pas évalué par un programme, faites ce qui vous semble le mieux du moment que
+  vous rendez les fichiers obligatoires.
+
+• Les consignes d’un exercice peuvent avoir l’air simple mais les exemples contiennent
+  parfois des indications supplémentaires qui ne sont pas explicitement demandées.
+
+• Lisez entièrement chaque module avant de commencer ! Vraiment.
+
+• Par Odin, par Thor ! Utilisez votre cervelle !!!
+
+                 4
+C++ - Module 09     STL
+
+Vous aurez à implémenter un bon nombre de classes, ce qui pourrait
+s’avérer ardu... ou pas ! Il y a peut-être moyen de vous simplifier
+la vie grâce à votre éditeur de texte préféré.
+
+Vous êtes assez libre quant à la manière de résoudre les exercices.
+Toutefois, respectez les consignes et ne vous en tenez pas au strict
+minimum, vous pourriez passer à côté de notions intéressantes.
+N’hésitez pas à lire un peu de théorie.
+
+                 5
+Chapter III
+Règles spécifiques au module
+
+Il est obligatoire d’utiliser les conteneurs standard pour effectuer chaque exercice dans ce
+module.
+
+    Une fois qu’un conteneur est utilisé, vous ne pouvez pas l’utiliser pour le reste du
+module.
+
+                     Il est conseillé de lire le sujet dans son intégralité avant de faire
+                     les exercices.
+
+                     Vous devez utiliser au moins un conteneur pour chaque exercice, à
+                     l’exception de l’exercice 02 qui nécessite l’utilisation de deux
+                     conteneurs.
+
+    Vous devez soumettre un Makefile pour chaque programme, qui compilera vos fichiers
+source pour produire la sortie requise avec les indicateurs -Wall, -Wextra and -Werror.
+
+    Vous devez utiliser C++, et votre Makefile ne doit pas recréer les liens (relink).
+    Votre Makefile doit contenir au moins les règles $(NAME), all, clean, fclean and
+re.
+
+                                                        6
+Chapter IV
+
+Exercice 00: Bitcoin Exchange
+
+                                                   Exercise : 00
+                                                    Bitcoin Exchange
+    Turn-in directory : ex00/
+    Files to turn in : Makefile, main.cpp, BitcoinExchange.{cpp, hpp}
+    Forbidden functions : None
+
+    Vous devez créer un programme qui affiche la valeur d’une certaine quantité de bitcoins
+à une certaine date.
+
+    Ce programme doit utiliser une base de données au format CSV qui représentera le
+prix du bitcoin au fil du temps. Cette base de données est fournie avec le sujet.
+
+    Le programme prendra en entrée une deuxième base de données stockant les différents
+prix / dates à évaluer.
+
+    Votre programme doit respecter ces règles:
+
+    • Le nom du programme est btc.
+    • Votre programme doit prendre un fichier en argument.
+    • Chaque ligne de ce fichier doit utiliser le format suivant: "date | valeur".
+    • Une date valide sera toujours au format "Année-Mois-Jour" (YYYY-MM-DD).
+    • Une valeur valide doit être soit un nombre à virgule flottante (float), ou un entier
+
+       positif, compris entre 0 et 1000.
+
+                     Vous devez utiliser au moins un conteneur dans votre code pour
+                     valider cet exercice. Vous devez gérer les erreurs possibles avec un
+                     message d’erreur approprié.
+
+                                                        7
+C++ - Module 09                                                   STL
+
+    Voici un exemple d’un fichier input.txt
+
+  $> head input.txt
+  date | value
+  2011-01-03 | 3
+  2011-01-03 | 2
+  2011-01-03 | 1
+  2011-01-03 | 1.2
+  2011-01-09 | 1
+  2012-01-11 | -1
+  2001-42-42
+  2012-01-11 | 1
+  2012-01-11 | 2147483648
+  $>
+
+    Votre programme va utiliser la valeur dans votre fichier input.
+
+    Votre programme doit afficher sur la sortie standard le résultat de la valeur multipliée
+par le taux de change en fonction de la date indiquée dans votre base de données.
+
+                     Si la date utilisée en entrée n’existe pas dans votre BD, alors vous
+
+                     devez utiliser la date la plus proche contenue dans votre BD. Soyez
+
+                     attentifs à utilser la date précédente la plus proche, et non la
+
+                     suivante.
+
+    L’exemple suivant démontre le fonctionnement de votre programme.
+
+  $> ./btc
+  Error: could not open file.
+  $> ./btc input.txt
+  2011-01-03 => 3 = 0.9
+  2011-01-03 => 2 = 0.6
+  2011-01-03 => 1 = 0.3
+  2011-01-03 => 1.2 = 0.36
+  2011-01-09 => 1 = 0.32
+  Error: not a positive number.
+  Error: bad input => 2001-42-42
+  2012-01-11 => 1 = 7.1
+  Error: too large a number.
+  $>
+
+Attention: les conteneurs que vous utilisez pour valider cet
+exercice ne pourront plus être utilisés pour le reste du module.
+
+                 8
+Chapter V
+
+Exercice 01: Reverse Polish
+Notation
+
+                                                   Exercise : 01
+                                                            RPN
+
+    Turn-in directory : ex01/
+    Files to turn in : Makefile, main.cpp, RPN.{cpp, hpp}
+    Forbidden functions : None
+
+    Vous devez créer un programme avec ces contraintes:
+    • Le nom du programme est RPN.
+    • Votre programme doit prendre en argument une expression mathématique en no-
+
+       tation polonaise inversée.
+    • Les chiffres utilisés dans cette opération et transmis en tant qu’arguments seront
+
+       toujours inférieurs à 10. Le calcul lui-même ainsi que le résultat ne tiennent pas
+       compte de cette règle.
+    • Votre programme doit traiter cette expression et afficher le résultat correct sur la
+       sortie standard.
+    • Si une erreur se produit pendant l’exécution du programme, un message d’erreur
+       doit être affiché sur la sortie d’erreur.
+    • Votre programme doit être capable de gérer les opérations avec ces opérateurs: "+
+       - / *".
+
+                     Vous devez utiliser au moins un conteneur dans votre code pour
+                     valider cet exercice.
+
+                                                        9
+C++ - Module 09                                                                 STL
+
+                Vous n’avez pas besoin de gérer les parenthèses ou les nombres
+                décimaux.
+
+Voici un exemple d’utilisation standard:
+
+  $> ./RPN "8 9 * 9 - 9 - 9 - 4 - 1 +"
+  42
+  $> ./RPN "7 7 * 7 -"
+  42
+  $> ./RPN "1 2 * 2 / 2 * 2 4 - +"
+  0
+  $> ./RPN "(1 + 1)"
+  Error
+  $>
+
+Attention: Le(s) conteneur(s) utilisé(s) dans l’exercice précédent
+sont interdits ici. Le(s) conteneur(s) utilisé(s) dans cet exercice
+ne pourront être réutilisés dans un autre exercice du module.
+
+                 10
+Chapter VI
+Exercice 02: PmergeMe
+
+                                                   Exercise : 02
+                                                        PmergeMe
+
+    Turn-in directory : ex02/
+    Files to turn in : Makefile, main.cpp, PmergeMe.{cpp, hpp}
+    Forbidden functions : None
+
+    Vous devez créer un programme avec ces contraintes:
+    • Le nom du programme est PmergeMe.
+    • Votre programme doit prendre une séquence d’entiers positif en argument.
+    • Votre programme doit utiliser l’algorithme de tri "merge-insert" pour trier la séquence
+
+       de nombres.
+
+                     Afin d’être clair, oui, vous devez utiliser l’algorithme
+                     Ford-Johnson.
+
+    • Si une erreur survient durant l’exécution du programme, un message d’erreur doit
+       être affiché sur la sortie d’erreur.
+
+                     Vous devez utiliser au moins deux conteneurs dans votre code afin de
+                     valider cet exercice. Votre programme doit pouvoir gérer au moins
+                     3000 entiers différents.
+
+                                                       11
+C++ - Module 09      STL
+
+                     Il est fortement recommandé d’implémenter votre algorithme pour
+                     chaque conteneurs utilisé et donc d’éviter d’utiliser une fonction
+                     générique.
+
+    Voici quelques directives supplémentaires sur l’information que vous devriez afficher
+sur la sortie standard:
+
+    • Sur la première ligne, vous devez afficher un texte explicite suivi de la séquence
+       d’entiers positifs non triés.
+
+    • Sur la deuxième ligne. vous devez afficher un texte explicite suivi de la séquence
+       d’entiers positifs triés.
+
+    • Sur la troisième ligne, vous devez afficher un texte explicite indiquant le temps
+       utilisé par votre algorithme en spécifiant le premier conteneur utilisé pour trier la
+       séquence d’entiers positifs.
+
+    • Sur la dernière ligne, vous devez afficher un texte explicite indiquant le temps
+       utilisé par votre algorithme en spécifiant le deuxième conteneur utilisé pour trier la
+       séquence d’entiers positifs.
+
+                 Le format d’affichage du temps utilisé pour effectuer votre tri est
+                 libre, mais la précision choisie doit permettre de voir clairement la
+                 différence entre les deux conteneurs utilisés.
+
+Voici un exemple d’utilisation standard:
+
+$> ./PmergeMe 3 5 9 7 4
+Before: 3 5 9 7 4
+After: 3 4 5 7 9
+Time to process a range of 5 elements with std::[..] : 0.00031 us
+Time to process a range of 5 elements with std::[..] : 0.00014 us
+$> ./PmergeMe `shuf -i 1-100000 -n 3000 | tr "\n" " "`
+Before: 141 79 526 321 [...]
+After: 79 141 321 526 [...]
+Time to process a range of 3000 elements with std::[..] : 62.14389 us
+Time to process a range of 3000 elements with std::[..] : 69.27212 us
+$> ./PmergeMe "-1" "2"
+Error
+$> # For OSX USER:
+$> ./PmergeMe `jot -r 3000 1 100000 | tr '\n' ' '`
+[...]
+$>
+
+                 L’indication du temps est délibérément étrange dans cet exemple.
+                 Bien sûr, vous devez indiquer le temps utilisé pour effectuer toutes
+                 vos opérations, à la fois la partie de tri et la partie de gestion
+                 des données.
+
+                 12
+C++ - Module 09                                                STL
+
+Attention: Les conteneurs utilisés dans les exercices précédents ne
+peuvent pas être utilisés ici.
+
+La gestion des erreurs liées aux doublons est laissée à votre
+discrétion.
+
+                 13
+Chapter VII
+Rendu et évaluation
+
+Rendez votre travail dans un répertoire Git comme d’habitude. Seulement le travail
+présent à l’intérieur du repo sera évalué lors de la défense. N’hésitez pas à revérifier les
+noms des dossiers et fichiers pour vous assurer qu’ils soient corrects.
+
+                     16D85ACC441674FBA2DF65190663F33F793984B142405F56715D5225FBAB6E3D6A4F
+                     167020A16827E1B16612137E59ECD492E47AB764CB10B45D979615AC9FC74D521D9
+                     20A778A5E
+
+                                                       14
+