From 94fb05a764c1d0d1f275f29ecd21686d835f9768 Mon Sep 17 00:00:00 2001 From: Steru Date: Mon, 12 Aug 2024 22:09:50 +0200 Subject: Created Model for competitors. --- src/model/MedalWinner.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/model/MedalWinner.cpp (limited to 'src/model/MedalWinner.cpp') 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; +} -- cgit v1.2.3