uestion) class Player:      total_player = 0      def __init__(self,name,country):          self.name = name          self.country = country      def __str__(self):

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Design TennisPlayer class which inherit from Player class so that the 
following code provides the expected output. 
[addGrandSlams() method should work any number of parameters assuming that 
the parameter number will be an even number and greater than 1]

(python question)

class Player:
     total_player = 0

     def __init__(self,name,country):
         self.name = name
         self.country = country

     def __str__(self):
         return  'Name: '+self.name+'\nCountry Name: '+str(self.country)


# Write your codes here.
# Do not change the following lines of code. Order of the year in printing 
grand slams doesn’t matter.
p1 = TennisPlayer("Novac Djokovic", 'Serbia')
print("==============================")
p1.addGrandSlams('Wimbledon',2021, 'French Open',2021,'Australian 
Open',2020)
print("==============================")
print(p1)
print("==============================")
p2 = TennisPlayer("Roger Federer", 'Switzerland')
print("==============================")
p2.addGrandSlams('Wimbledon',2017, 'US Open',2008,'Australian 
Open',2017,'Australian Open',2018)
print("==============================")
print(p2)
print("==============================")
print('Total Players: ', Player.total_player)

OUTPUT:
New Tennis Player Added - Novac Djokovic from Serbia
==============================
==============================
Name: Novac Djokovic
Country Name: Serbia
Grand Slams:
2021: ['Wimbledon','French Open']
2020: ['Australian Open']
==============================
New Tennis Player Added - Roger Federer from Switzerland
==============================
==============================
Name: Roger Federer
Country Name: Switzerland
Grand Slams:
2018: ['Australian Open']
2017: ['Wimbledon','Australian Open']
2008: ['US Open']
==============================
Total Players: 2

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education