From 6d7420d343eb5397875f7d492ffd020956f1b035 Mon Sep 17 00:00:00 2001 From: "antoine.perederii" Date: Fri, 10 Feb 2023 10:37:18 +0100 Subject: [PATCH] ajout du tp 3 de Cpp --- Algo/tp/Cpp/3_tp/.vscode/settings.json | 5 ++++ Algo/tp/Cpp/3_tp/src/passager.hpp | 2 ++ Algo/tp/Cpp/3_tp/src/test.cpp | 4 +-- Algo/tp/Cpp/3_tp/src/wagon.cpp | 8 ++++-- Algo/tp/Cpp/3_tp/src/wagon.hpp | 5 ++-- BDD/tp/BDDs2/tp1/jo.sql | 1 - BDD/tp/BDDs2/tp1/requetes_tp3.sql | 40 ++++++++++++++++++++++++++ 7 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 Algo/tp/Cpp/3_tp/.vscode/settings.json create mode 100644 BDD/tp/BDDs2/tp1/requetes_tp3.sql diff --git a/Algo/tp/Cpp/3_tp/.vscode/settings.json b/Algo/tp/Cpp/3_tp/.vscode/settings.json new file mode 100644 index 0000000..ce48fa6 --- /dev/null +++ b/Algo/tp/Cpp/3_tp/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "iosfwd": "cpp" + } +} \ No newline at end of file diff --git a/Algo/tp/Cpp/3_tp/src/passager.hpp b/Algo/tp/Cpp/3_tp/src/passager.hpp index ac0dd1f..1df41e5 100644 --- a/Algo/tp/Cpp/3_tp/src/passager.hpp +++ b/Algo/tp/Cpp/3_tp/src/passager.hpp @@ -17,6 +17,8 @@ public : Passager(std::string nom, std::string prenom); Wagon getWagonActuel() const; + + friend std::ostream &operator<<(std::ostream &s, const Passager &p); ~Passager(); }; diff --git a/Algo/tp/Cpp/3_tp/src/test.cpp b/Algo/tp/Cpp/3_tp/src/test.cpp index eea10aa..541572e 100644 --- a/Algo/tp/Cpp/3_tp/src/test.cpp +++ b/Algo/tp/Cpp/3_tp/src/test.cpp @@ -24,7 +24,7 @@ void testTrain(void) { int main() { testPassager(); - testWagon(); - testTrain(); + // testWagon(); + // testTrain(); return 0; } \ No newline at end of file diff --git a/Algo/tp/Cpp/3_tp/src/wagon.cpp b/Algo/tp/Cpp/3_tp/src/wagon.cpp index 035e18d..a6c853b 100644 --- a/Algo/tp/Cpp/3_tp/src/wagon.cpp +++ b/Algo/tp/Cpp/3_tp/src/wagon.cpp @@ -22,6 +22,8 @@ int Wagon::enlever(Passager lePassager) { return 0; } -// ostream &operator<<(ostream &s, const Passager &p) { - -// } \ No newline at end of file +ostream &operator<<(ostream &s, const Passager &p) { + s << "Wagon n° " << w.numero << " : " << w.nbPassagers->size() << " passager(s)." << endl; + s << "Reste " << w.capacite - w.nbPassagers->size() << " places(s)." << endl; + s << "Liste des passagers :\n" << w. +} \ No newline at end of file diff --git a/Algo/tp/Cpp/3_tp/src/wagon.hpp b/Algo/tp/Cpp/3_tp/src/wagon.hpp index 7d62cc4..e95b9b4 100644 --- a/Algo/tp/Cpp/3_tp/src/wagon.hpp +++ b/Algo/tp/Cpp/3_tp/src/wagon.hpp @@ -21,10 +21,11 @@ public : int ajouter(Passager lePassager); int enlever(Passager lePassager); - + + friend std::ostream &operator<<(std::ostream &s, const Passager &w); + ~Wagon() = default; //~Wagon(){}; }; -std::ostream &operator<<(std::ostream &s, const Passager &p); #endif // WAGON_HPP \ No newline at end of file diff --git a/BDD/tp/BDDs2/tp1/jo.sql b/BDD/tp/BDDs2/tp1/jo.sql index ff0dd50..294e758 100644 --- a/BDD/tp/BDDs2/tp1/jo.sql +++ b/BDD/tp/BDDs2/tp1/jo.sql @@ -5,6 +5,5 @@ \i pratiquer.sql \i epreuve.sql \i resultats.sql -\i requetes.sql \d diff --git a/BDD/tp/BDDs2/tp1/requetes_tp3.sql b/BDD/tp/BDDs2/tp1/requetes_tp3.sql new file mode 100644 index 0000000..98da80d --- /dev/null +++ b/BDD/tp/BDDs2/tp1/requetes_tp3.sql @@ -0,0 +1,40 @@ +-- Question 1 +SELECT d.* +FROM Discipline d, Epreuve e +WHERE d.code=e.discipl AND e.dateE < '2021-08-01' AND e.dateE > '2021-06-30' +GROUP BY d.code +HAVING count(*) >=ALL (SELECT count(*) +FROM Epreuve +WHERE dateE >= '2021-08-01' AND dateE <= '2021-08-31' AND d.code=discipl); + +-- code | nom +-- ------+----------------------- +-- FEN | Fencing +-- JUD | Judo +-- TKW | Taekwondo +-- GTR | Trampoline Gymnastics +-- TRI | Triathlon +-- TTE | Table Tennis +-- CRD | Cycling Road +-- SKB | Skateboarding +-- SWM | Swimming +-- BK3 | 3x3 Basketball +-- SRF | Surfing +-- ROW | Rowing +-- RUG | Rugby Sevens +-- BSB | Baseball/Softball +-- DIV | Diving +-- SHO | Shooting +-- BMX | Cycling BMX Racing +-- CSL | Canoe Slalom +-- ARC | Archery +-- TEN | Tennis +-- WLF | Weightlifting + +-- Question 2 +SELECT p.nom +FROM pays p, Athlete a, Resultat r +WHERE + +-- Question 3 +SELECT \ No newline at end of file