t change the given code. country1 = OlympicCountry('Jamaica') country2 = OlympicCountry('USA') player1 = AwardedPlayer('Usain Bolt') player2 = AwardedPlayer('Shelly-Ann Fraser-Pryce','Silver') player3 = AwardedPlayer('Elaine Thompson Herah','Gold') player4 = AwardedPlayer('Michael Phelps','Gold') player5 = AwardedPlayer('Caeleb Dressel','Gold') print('-----------------------------------------') country1.add_player(player1) print('-----------------------------------------') player1.add_medal('Gold') country1.add_player(player1) country1.add_player(player2) country1.add_player(player3) print('-----------------------------------------') country1.show_medal_info() print('-----------------------------------------') country2.add_player(player4) country2.add_player(player5) print('-----------------------------------------') country2.show_medal_info() Expected Output: ----------------------------------------- A player must have a medal. Add the medal first -----------------
Write the OlympicCountry and AwardedPlayer class so that the given code provides the expected output. You can not change the given code. country1 = OlympicCountry('Jamaica') country2 = OlympicCountry('USA') player1 = AwardedPlayer('Usain Bolt') player2 = AwardedPlayer('Shelly-Ann Fraser-Pryce','Silver') player3 = AwardedPlayer('Elaine Thompson Herah','Gold') player4 = AwardedPlayer('Michael Phelps','Gold') player5 = AwardedPlayer('Caeleb Dressel','Gold') print('-----------------------------------------') country1.add_player(player1) print('-----------------------------------------') player1.add_medal('Gold') country1.add_player(player1) country1.add_player(player2) country1.add_player(player3) print('-----------------------------------------') country1.show_medal_info() print('-----------------------------------------') country2.add_player(player4) country2.add_player(player5) print('-----------------------------------------') country2.show_medal_info() Expected Output: ----------------------------------------- A player must have a medal. Add the medal first ----------------------------------------- ----------------------------------------- Total medals won by Jamaica is 3 ****** Gold ['Usain Bolt', 'Elaine Thompson Herah'] Silver ['Shelly-Ann Fraser-Pryce'] Bronze [] ----------------------------------------- ----------------------------------------- Total medals won by USA is 2 ****** Gold ['Michael Phelps', 'Caeleb Dressel'] Silver [] Bronze []
Step by step
Solved in 4 steps with 3 images