diff options
author | Steru <jerrydream111@gmail.com> | 2024-08-12 22:09:50 +0200 |
---|---|---|
committer | Steru <jerrydream111@gmail.com> | 2024-08-12 22:09:50 +0200 |
commit | 94fb05a764c1d0d1f275f29ecd21686d835f9768 (patch) | |
tree | 283d60ee309ca35132c3cd64b55d018cc2cbfc87 /src/model/MedalWinner.cpp | |
parent | c539242efa11538e5e3f91bf3ff2f0de1c526bed (diff) |
Created Model for competitors.
Diffstat (limited to 'src/model/MedalWinner.cpp')
-rw-r--r-- | src/model/MedalWinner.cpp | 18 |
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; +} |