diff options
author | Steru <jerrydream111@gmail.com> | 2024-08-16 15:39:05 +0200 |
---|---|---|
committer | Steru <jerrydream111@gmail.com> | 2024-08-16 15:59:22 +0200 |
commit | 3918de89ce74bea2f18f814edc9accad4af9d818 (patch) | |
tree | b86013c6be31e0f2caec6e00dd9cc82cfa194ad1 /src/model/MedalWinner.h | |
parent | 66d5d8685f7dcd45b2e9581315c101e69646cd6f (diff) |
Fixed constructors.
Diffstat (limited to 'src/model/MedalWinner.h')
-rw-r--r-- | src/model/MedalWinner.h | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/model/MedalWinner.h b/src/model/MedalWinner.h index 45d1ee8..10d08bd 100644 --- a/src/model/MedalWinner.h +++ b/src/model/MedalWinner.h @@ -4,7 +4,6 @@ #include "Competitor.h" #include <QMap> #include <QJsonObject> -#include <stdexcept> #include <QAbstractListModel> @@ -17,16 +16,17 @@ class MedalWinner : public Competitor { Q_PROPERTY(int bronze READ m_bronze NOTIFY nBronze) public: - MedalWinner() : Competitor(), m_gold(0), m_silver(0), m_bronze(0) {} - MedalWinner(const MedalWinner &medalWinner) : Competitor(medalWinner), - m_gold(medalWinner.m_gold), m_silver(medalWinner.m_silver), m_bronze(medalWinner.m_bronze) {} - MedalWinner(const QJsonObject &competitor) : Competitor(competitor) { - if (!competitor.contains("medals")) throw invalid_argument("Competitor has no medals."); - QJsonObject medals = competitor["medals"].toObject(); - setMedals(medals); - } + explicit MedalWinner(Competitor *parent) : Competitor(parent) {} + + bool setMedalWinner(const QJsonObject &competitor); + void setMedalWinner(const MedalWinner &competitor); bool setMedals(const QJsonObject &medals); + + void setGold(int gold) { this->m_gold = gold; } + void setSilver(int silver) { this->m_silver = silver; } + void setBronze(int bronze) { this->m_bronze = bronze; } + int getGold() { return m_gold; } int getSilver() { return m_silver; } int getBronze() { return m_bronze; } |