Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this question I have added the tennis player class below to help with the question it is in python A TennisTournament

I need help with this question I have added the tennis player class below to help with the question it is in python

image text in transcribedimage text in transcribed

A TennisTournament class maintains exactly 8 tennis players, where the details of each tennis player are stored using instances of the Tennisplayer class. You can assume that the Tennisplayer class from the previous question has been provided for you, so you can use e.g. the get_current_rank() method. The Tennis Tournament class contains the following: A private data field named tournament_name that defines the name of the tournament. A private dictionary data field named players that stores TennisPlayer objects based on their ranking. A constructor/initializer that takes a tournament name as a parameter and creates a TennisTournament object. The get_tournament_name(self) method which returns the name of the tournament. The add_player(self, player) method which takes a Tennisplayer object as a parameter and adds it to the data structure organizing the players of a tournament. You may assume that no two players can have the same ranking. If more than eight players want to play in a tournament, this method has to ignore the additional player and it has to print an error message (ERROR: Roster is full!). The get_first_round_matches (self) method which will first check if there are eight players added to a tournament. If this is not the case an error message is printed (ERROR: Creating matches requires 8 players!). Otherwise, the first round matches are created, such that the best ranked player plays the lowest ranked player, the second best ranked plays the second lowest, and so on. Return the matches as a list of tuples, where the first entry of every tuple is the higher ranked player of the respective match, and the second entry of every tuple the lower ranked player. Note: Submit the entire TennisTournament class definition in the answer box. You can assume that the Tennisplayer class is given. For example: Test Result Frenchopen Djokovic, Novak(1) vs Venus, Michael (274) Nadal, Rafael(2) Vs Isner, John(23) Thiem, Dominic(3) vs Carreno Busta, Pablo(15) Zverev, Alexander(7) vs Berrettini, Marco(9) tournament = TennisTournament("Frenchopen) tournament.add_player(TennisPlayer('Venus', 'Michael', 274) tournament.add_player(Tennisplayer("zverev', 'Alexander', 7)) tournament.add_player(TennisPlayer('Djokovic', 'Novak', 1)) tournament.add_player(TennisPlayer('Thiem', 'Dominic', 3)) tournament.add_player(Tennisplayer('Berrettini', 'Marco', 9)) tournament.add_player(Tennisplayer("Nadal', 'Rafael', 2)) tournament.add_player(Tennisplayer('Isner', 'John', 23)) tournament.add_player(TennisPlayer('Carreno Busta', 'Pablo', 15)) matches = tournament.get_first_round_matches) print(tournament.get_tournament_name()) for pair in matches: rank_playeri = pair[@].get_current_rank rank_player2 = pair[1].get_current_rank) print("{}({}) vs {}{{})".Format(pair[e].get_names(), rank_playeri, pair[1].get_names(), rank_player2)) tournament = TennisTournament('Frenchopen') tournament.add_player(Tennisplayer('Halep', 'Simona', 2)) matches = tournament.get_first_round_matches) ERROR: creating matches requires & players! 1 class TennisPlayer: 2 def __init__(self, surname, firstname, current_rank, total_prize_money = 0): 3 self surname = surname self._firstname = firstname 5 self._current_rank = current_rank 6 self.__total_prize_money = total_prize_money 7 def get_names(self): 8 return "{}, {}".Format(self.__surname, self._firstname) 9 def get_current_rank(self): 10 return self._current_rank 11, def get_total_prize_money (self): 12 return self._total_prize_money 13 def set_total_prize_money(self, total_prize_money): 14 if total_prize_money > 0: 15 self._total_prize_money = total_prize_money 16 def str_(self): 17 return "{}, } (rank {}), total prize money (millions) = ${}".Format(self._surname, self.__firstname, self._current_rank, self._total_prize_money)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions

Question

Knowledge of process documentation (process flow charting)

Answered: 1 week ago