summaryrefslogtreecommitdiff
path: root/src/model/MedalWinner.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/MedalWinner.h')
-rw-r--r--src/model/MedalWinner.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/model/MedalWinner.h b/src/model/MedalWinner.h
new file mode 100644
index 0000000..e771185
--- /dev/null
+++ b/src/model/MedalWinner.h
@@ -0,0 +1,35 @@
+
+#ifndef ITAT_CHALLANGE_OLYMPICS_MEDALWINNER_H
+#define ITAT_CHALLANGE_OLYMPICS_MEDALWINNER_H
+
+#include "Competitor.h"
+#include <QMap>
+#include <QJsonObject>
+#include <stdexcept>
+
+class MedalWinner : public Competitor {
+
+public:
+ MedalWinner(const MedalWinner &medalWinner) : Competitor(medalWinner) {
+ this->wonMedals = {
+ {QString("ME_GOLD"), medalWinner.wonMedals.value("ME_GOLD")},
+ {QString("ME_SILVER"), medalWinner.wonMedals.value("ME_SILVER")},
+ {QString("ME_BRONZE"), medalWinner.wonMedals.value("ME_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);
+ }
+
+ bool setMedals(const QJsonObject &medals);
+
+private:
+ QMap<QString, QString> wonMedals;
+
+};
+
+
+#endif //ITAT_CHALLANGE_OLYMPICS_MEDALWINNER_H