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