diff --git a/Algo/tp/Cpp/3_tp/3_tp.zip b/Algo/tp/Cpp/3_tp/3_tp.zip new file mode 100644 index 0000000..95b4ba8 Binary files /dev/null and b/Algo/tp/Cpp/3_tp/3_tp.zip differ diff --git a/Algo/tp/Cpp/3_tp/bin/exe b/Algo/tp/Cpp/3_tp/bin/exe index 235925a..3c1c587 100755 Binary files a/Algo/tp/Cpp/3_tp/bin/exe and b/Algo/tp/Cpp/3_tp/bin/exe differ diff --git a/Algo/tp/Cpp/3_tp/obj/passager.o b/Algo/tp/Cpp/3_tp/obj/passager.o index 6c74a59..2c51305 100644 Binary files a/Algo/tp/Cpp/3_tp/obj/passager.o and b/Algo/tp/Cpp/3_tp/obj/passager.o differ diff --git a/Algo/tp/Cpp/3_tp/obj/test.o b/Algo/tp/Cpp/3_tp/obj/test.o index c6cfa99..a29a512 100644 Binary files a/Algo/tp/Cpp/3_tp/obj/test.o and b/Algo/tp/Cpp/3_tp/obj/test.o differ diff --git a/Algo/tp/Cpp/3_tp/src/passager.cpp b/Algo/tp/Cpp/3_tp/src/passager.cpp index c35eaf5..48004bd 100644 --- a/Algo/tp/Cpp/3_tp/src/passager.cpp +++ b/Algo/tp/Cpp/3_tp/src/passager.cpp @@ -14,7 +14,7 @@ Wagon Passager::getWagonActuel() const { } ostream &operator<<(ostream &s, const Passager &p) { - s << "Passager : " << p.nom << p.prenom << endl; + s << "Passager : " << p.nom << " " << p.prenom << endl; return s; } diff --git a/Algo/tp/Cpp/3_tp/src/test.cpp b/Algo/tp/Cpp/3_tp/src/test.cpp index 1c3ce73..b4163c1 100644 --- a/Algo/tp/Cpp/3_tp/src/test.cpp +++ b/Algo/tp/Cpp/3_tp/src/test.cpp @@ -13,18 +13,28 @@ void testPassager(void) { } void testWagon(void) { - Wagon leWagon(1); - cout << leWagon << endl; + Wagon w1(1); + Wagon w2(2); + Wagon w3(3); + Passager lePassager("Maurice", "Mitchel"); + Passager lePassager2("Pierre", "Roberts"); + Passager lePassager3("Jean", "Dupont"); + w1.ajouter(lePassager); + w1.ajouter(lePassager2); + w3.ajouter(lePassager3); + cout << w1 << endl; + cout << w2 << endl; + cout << w3 << endl; } -// void testTrain(void) { -// Train leTrain("Train 1"); -// cout << leTrain.getNom() << endl; -// } +void testTrain(void) { + Train leTrain(1); + cout << leTrain << endl; +} int main() { - testPassager(); - // testWagon(); - // testTrain(); + // testPassager(); + testWagon(); + //testTrain(); return 0; } \ No newline at end of file diff --git a/Algo/tp/Cpp/3_tp/src/train.cpp b/Algo/tp/Cpp/3_tp/src/train.cpp index 702f2be..acc13ce 100644 --- a/Algo/tp/Cpp/3_tp/src/train.cpp +++ b/Algo/tp/Cpp/3_tp/src/train.cpp @@ -22,4 +22,18 @@ void Train::arreter() { bool Train::isRoule() const { return roule; +} + +ostream &operator<<(ostream &s, const Train &t) { + s << "Train : " << t.lesWagons.size() << " wagon(s)." << endl; + s << "Liste des wagons :\n"; + for (Wagon* w : t.lesWagons) + { + s << "\t" << "Wagon n°" << w->numero << " : " << w->lesPassagers.size() << " passager(s)." << endl; + s << "\t" << "Reste " << w->capacite - w->lesPassagers.size() << " places(s)." << endl; + s << "\t" << "Liste des passagers :\n"; + for (Passager* p : w->lesPassagers) + s << "\t\t" << *p << endl; + } + return s; } \ No newline at end of file