summaryrefslogtreecommitdiff
path: root/src/model/MedalWinner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/MedalWinner.cpp')
-rw-r--r--src/model/MedalWinner.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/model/MedalWinner.cpp b/src/model/MedalWinner.cpp
new file mode 100644
index 0000000..c4cb663
--- /dev/null
+++ b/src/model/MedalWinner.cpp
@@ -0,0 +1,18 @@
+
+#include "MedalWinner.h"
+
+bool MedalWinner::setMedals(const QJsonObject &medals) {
+ if (!medals.contains("ME_GOLD")
+ || !medals.contains("ME_SILVER")
+ || !medals.contains("ME_BRONZE")) {
+ throw invalid_argument("Medal object of competitor is incomplete.");
+ }
+
+ this->wonMedals = {
+ {QString("ME_GOLD"), medals["ME_GOLD"].toString()},
+ {QString("ME_SILVER"), medals["ME_SILVER"].toString()},
+ {QString("ME_BRONZE"), medals["ME_BRONZE"].toString()}
+ };
+
+ return true;
+}