From 4077114c96174648f4839ee460e6149921397df4 Mon Sep 17 00:00:00 2001 From: theking90000 Date: Thu, 28 Nov 2024 13:48:19 +0100 Subject: [PATCH] TP7: formattage --- TP7/Entreprise.cpp | 9 ++++- TP7/Pays.cpp | 9 ++++- .../Entreprise.cpp | 39 ++++++++++++++++++ .../Entreprise.cpp | 32 +++++++++++++++ .../Entreprise.cpp | 39 ++++++++++++++++++ .../Entreprise.cpp | 40 +++++++++++++++++++ TP7/getio.h | 12 ++++++ 7 files changed, 178 insertions(+), 2 deletions(-) create mode 100644 TP7/enc_temp_folder/30384f7c97f259fa9ab49b708272edbc/Entreprise.cpp create mode 100644 TP7/enc_temp_folder/7e95deb3ffa611657e2a745bc92c682f/Entreprise.cpp create mode 100644 TP7/enc_temp_folder/8aea7bc1ea2ce5a02475a187f1a88967/Entreprise.cpp create mode 100644 TP7/enc_temp_folder/c1fa4c41809aeb7435453066aef6f5de/Entreprise.cpp diff --git a/TP7/Entreprise.cpp b/TP7/Entreprise.cpp index 617fc34..b369c53 100644 --- a/TP7/Entreprise.cpp +++ b/TP7/Entreprise.cpp @@ -16,7 +16,14 @@ void Entreprise::saisie(ifstream& s) { } void Entreprise::affichage() { - cout << m_company << " " << m_country << " " << m_market_value << " " << m_sector << " " << m_turnover << " " << m_employees << " " << m_rank_2015 << " " << m_rank_2014; + format(m_company, 20); + format(m_country, 15); + format(m_market_value, 10); + format(m_sector, 10); + format(m_turnover, 10); + format(m_employees, 6); + format(m_rank_2015, 3); + format(m_rank_2014, 3); } int Entreprise::rank_progress() const { diff --git a/TP7/Pays.cpp b/TP7/Pays.cpp index 3013977..49199a6 100644 --- a/TP7/Pays.cpp +++ b/TP7/Pays.cpp @@ -2,6 +2,8 @@ #include "Pays.h" #include +#include +#include "getio.h" using namespace std; @@ -14,5 +16,10 @@ void Pays::saisie(ifstream &in) { } void Pays::affichage() { - cout << Region << " " << Nom << " " << Population; + // format(Region, 10); + format(Nom, 20); + cout << setprecision(10); + format(Population, 10); + format(Area, 10); + // << setprecision(10) << Population << " " << Area; } \ No newline at end of file diff --git a/TP7/enc_temp_folder/30384f7c97f259fa9ab49b708272edbc/Entreprise.cpp b/TP7/enc_temp_folder/30384f7c97f259fa9ab49b708272edbc/Entreprise.cpp new file mode 100644 index 0000000..b369c53 --- /dev/null +++ b/TP7/enc_temp_folder/30384f7c97f259fa9ab49b708272edbc/Entreprise.cpp @@ -0,0 +1,39 @@ +#include "Entreprise.h" + +using namespace std; + +void Entreprise::saisie(ifstream& s) { + string tmp; + + getline(s, m_company, ';'); + getline(s, m_country, ';'); + getfloat(s, m_market_value, ';'); + getline(s, m_sector, ';'); + getfloat(s, m_turnover, ';'); + getfloat(s, m_employees, ';'); + getint(s, m_rank_2015, ';'); + getint(s, m_rank_2014, ';'); +} + +void Entreprise::affichage() { + format(m_company, 20); + format(m_country, 15); + format(m_market_value, 10); + format(m_sector, 10); + format(m_turnover, 10); + format(m_employees, 6); + format(m_rank_2015, 3); + format(m_rank_2014, 3); +} + +int Entreprise::rank_progress() const { + return m_rank_2014 - m_rank_2015; +} + +float Entreprise::turnover_empl() const { + return (float)m_turnover / m_employees; +} + +float Entreprise::getTurnover() const { + return m_turnover; +} \ No newline at end of file diff --git a/TP7/enc_temp_folder/7e95deb3ffa611657e2a745bc92c682f/Entreprise.cpp b/TP7/enc_temp_folder/7e95deb3ffa611657e2a745bc92c682f/Entreprise.cpp new file mode 100644 index 0000000..617fc34 --- /dev/null +++ b/TP7/enc_temp_folder/7e95deb3ffa611657e2a745bc92c682f/Entreprise.cpp @@ -0,0 +1,32 @@ +#include "Entreprise.h" + +using namespace std; + +void Entreprise::saisie(ifstream& s) { + string tmp; + + getline(s, m_company, ';'); + getline(s, m_country, ';'); + getfloat(s, m_market_value, ';'); + getline(s, m_sector, ';'); + getfloat(s, m_turnover, ';'); + getfloat(s, m_employees, ';'); + getint(s, m_rank_2015, ';'); + getint(s, m_rank_2014, ';'); +} + +void Entreprise::affichage() { + cout << m_company << " " << m_country << " " << m_market_value << " " << m_sector << " " << m_turnover << " " << m_employees << " " << m_rank_2015 << " " << m_rank_2014; +} + +int Entreprise::rank_progress() const { + return m_rank_2014 - m_rank_2015; +} + +float Entreprise::turnover_empl() const { + return (float)m_turnover / m_employees; +} + +float Entreprise::getTurnover() const { + return m_turnover; +} \ No newline at end of file diff --git a/TP7/enc_temp_folder/8aea7bc1ea2ce5a02475a187f1a88967/Entreprise.cpp b/TP7/enc_temp_folder/8aea7bc1ea2ce5a02475a187f1a88967/Entreprise.cpp new file mode 100644 index 0000000..875fcde --- /dev/null +++ b/TP7/enc_temp_folder/8aea7bc1ea2ce5a02475a187f1a88967/Entreprise.cpp @@ -0,0 +1,39 @@ +#include "Entreprise.h" + +using namespace std; + +void Entreprise::saisie(ifstream& s) { + string tmp; + + getline(s, m_company, ';'); + getline(s, m_country, ';'); + getfloat(s, m_market_value, ';'); + getline(s, m_sector, ';'); + getfloat(s, m_turnover, ';'); + getfloat(s, m_employees, ';'); + getint(s, m_rank_2015, ';'); + getint(s, m_rank_2014, ';'); +} + +void Entreprise::affichage() { + // format(m_company, 20); + format(m_country, 15); + format(m_market_value, 10); + format(m_sector, 10); + format(m_turnover, 10); + format(m_employees, 6); + format(m_rank_2015, 3); + format(m_rank_2014, 3); +} + +int Entreprise::rank_progress() const { + return m_rank_2014 - m_rank_2015; +} + +float Entreprise::turnover_empl() const { + return (float)m_turnover / m_employees; +} + +float Entreprise::getTurnover() const { + return m_turnover; +} \ No newline at end of file diff --git a/TP7/enc_temp_folder/c1fa4c41809aeb7435453066aef6f5de/Entreprise.cpp b/TP7/enc_temp_folder/c1fa4c41809aeb7435453066aef6f5de/Entreprise.cpp new file mode 100644 index 0000000..a57dc1b --- /dev/null +++ b/TP7/enc_temp_folder/c1fa4c41809aeb7435453066aef6f5de/Entreprise.cpp @@ -0,0 +1,40 @@ +#include "Entreprise.h" + +using namespace std; + +void Entreprise::saisie(ifstream& s) { + string tmp; + + getline(s, m_company, ';'); + getline(s, m_country, ';'); + getfloat(s, m_market_value, ';'); + getline(s, m_sector, ';'); + getfloat(s, m_turnover, ';'); + getfloat(s, m_employees, ';'); + getint(s, m_rank_2015, ';'); + getint(s, m_rank_2014, ';'); +} + +void Entreprise::affichage() { + format(m_company, 20); + format(m_country, 15); + format(m_market_value, 10); + format(m_sector, 10); + format(m_turnover, 10); + format(m_employees, 10); + format(m_employees, 10); + format(m_rank_2015, 10); + format(m_rank_2014, 10); +} + +int Entreprise::rank_progress() const { + return m_rank_2014 - m_rank_2015; +} + +float Entreprise::turnover_empl() const { + return (float)m_turnover / m_employees; +} + +float Entreprise::getTurnover() const { + return m_turnover; +} \ No newline at end of file diff --git a/TP7/getio.h b/TP7/getio.h index b4a8a57..10c6ca9 100644 --- a/TP7/getio.h +++ b/TP7/getio.h @@ -1,9 +1,21 @@ #pragma once #include +#include +#include using namespace std; void getfloat(ifstream& s, float& f, const char sep); void getint(ifstream& s, int& f, const char sep); + +template +void format(T t, int w) { + cout << left << setw(w) << t << " "; +} + +template +void format(T t) { + format(t, 4); +} \ No newline at end of file