#ifndef ITAT_CHALLANGE_OLYMPICS_MEDALWINNER_H #define ITAT_CHALLANGE_OLYMPICS_MEDALWINNER_H #include "Competitor.h" #include #include #include 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 wonMedals; }; #endif //ITAT_CHALLANGE_OLYMPICS_MEDALWINNER_H