#pragma once #include "Competitor.h" #include #include #include #include class MedalWinner : public Competitor { Q_OBJECT Q_PROPERTY(int gold READ gold NOTIFY nGold) Q_PROPERTY(int silver READ silver NOTIFY nSilver) Q_PROPERTY(int bronze READ bronze NOTIFY nBronze) public: MedalWinner() : Competitor() { this->gold = 0; this->silver = 0; this->bronze = 0; } MedalWinner(const MedalWinner &medalWinner) : Competitor(medalWinner) { this->gold = medalWinner.gold; this->silver = medalWinner.silver; this->bronze = medalWinner.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); int getGold() { return gold; } int getSilver() { return silver; } int getBronze() { return bronze; } static bool compare(MedalWinner lComp, MedalWinner rComp); private: int gold, silver, bronze; };