python question Design BDTeam class and AusTeam class which inherit from CricketTeam class so that the following code provides the expected output. You can not change any of the given code. Do not modify the given parent class. Note: add_player() method in both child classes should work for any number of parameters and assume parameters will be even numbers. class CricketTeam: def __init__(self, name, ranking, continent): self.name = name self.ranking = ranking self.continent = continent def add_player(self, *info): pass def __str__(self): s = f"Name: {self.name}\nRanking: {self.ranking}\nContinent: {self.continent}" return s # Write your codes here. # Do not change the following lines of code. bangladesh = BDTeam("Bangladesh", 7, "South Asia", 1) bangladesh.add_player("Mustafiz", "Bowler", "Mashrafee", "Bowler", "Shakib", "All Rounder", "Tamim", "Batter", "Mahmudullah", "Batter") print('1.------------------------------------') print(bangladesh.asia_cup_status()) print('2.------------------------------------') print(bangladesh) print('3.====================================') australia = AusTeam("Australia", 3, "Oceania", 5) australia.add_player("Batter", "Smith", "All Rounder", "Marsh", "Batter", "David", "Bowler", "Starc", "Bowler", "Hazlewood") print('4.------------------------------------') print(australia.world_cup_status()) print('5.------------------------------------') print(australia) OUTPUT: 1.------------------------------------ Hurray!!! Bangladesh has won 1 Asia Cups!!! 2.------------------------------------ Country Details: Name: Bangladesh Ranking: 7 Continent: South Asia Asia Cup Win:1 Players: Bowler: ['Mustafiz', 'Mashrafee'] All Rounder: ['Shakib'] Batter: ['Tamim', 'Mahmudullah'] 3.==================================== 4.------------------------------------ Hurray!!! Australia has won 5 World Cups!!! 5.------------------------------------ Country Details: Name: Australia Ranking: 3 Continent: Oceania World Cup Win:5 Players: Batter: ['Smith', 'David'] All Rounder: ['Marsh'] Bowler: ['Starc', 'Hazlewood']
python question
Design BDTeam class and AusTeam class which inherit from CricketTeam class
so that the following code provides the expected output.
You can not change any of the given code. Do not modify the given parent
class.
Note:
add_player() method in both child classes should work for any number of
parameters and assume parameters will be even numbers.
class CricketTeam:
def __init__(self, name, ranking, continent):
self.name = name
self.ranking = ranking
self.continent = continent
def add_player(self, *info):
pass
def __str__(self):
s = f"Name: {self.name}\nRanking: {self.ranking}\nContinent:
{self.continent}"
return s
# Write your codes here.
# Do not change the following lines of code.
bangladesh = BDTeam("Bangladesh", 7, "South Asia", 1)
bangladesh.add_player("Mustafiz", "Bowler", "Mashrafee", "Bowler", "Shakib", "All
Rounder", "Tamim", "Batter", "Mahmudullah", "Batter")
print('1.------------------------------------')
print(bangladesh.asia_cup_status())
print('2.------------------------------------')
print(bangladesh)
print('3.====================================')
australia = AusTeam("Australia", 3, "Oceania", 5)
australia.add_player("Batter", "Smith", "All
Rounder", "Marsh", "Batter", "David", "Bowler", "Starc", "Bowler", "Hazlewood")
print('4.------------------------------------')
print(australia.world_cup_status())
print('5.------------------------------------')
print(australia)
OUTPUT:
1.------------------------------------
Hurray!!! Bangladesh has won 1 Asia Cups!!!
2.------------------------------------
Country Details:
Name: Bangladesh
Ranking: 7
Continent: South Asia
Asia Cup Win:1
Players:
Bowler: ['Mustafiz', 'Mashrafee']
All Rounder: ['Shakib']
Batter: ['Tamim', 'Mahmudullah']
3.====================================
4.------------------------------------
Hurray!!! Australia has won 5 World Cups!!!
5.------------------------------------
Country Details:
Name: Australia
Ranking: 3
Continent: Oceania
World Cup Win:5
Players:
Batter: ['Smith', 'David']
All Rounder: ['Marsh']
Bowler: ['Starc', 'Hazlewood']
Algorithm:
- Start
- Create a class BDTeam which inherits CricketTeam and which has attributes name,ranking,continent,wonTimes,bowlers,batters,allRounders
- Implement constructor which initializes the data
- Implement add_player() method, which adds players. If the player is bowler, add to bowler list, if the player is batter, add to batter list and if the player is allRounder, add to allRounder list
- Implement str() method, which displays data in given format
- Implement asia_cup_status() which print wonTimes
- Create a class AusTeam which inherits CricketTeam and which has attributes name,ranking,continent,wonTimes,bowlers,batters,allRounders
- Implement constructor which initializes the data
- Implement add_player() method, which adds players. If the player is bowler, add to bowler list, if the player is batter, add to batter list and if the player is allRounder, add to allRounder list
- Implement str() method, which displays data in given format
- Implement world_cup_status() which print wonTimes
- In the main method, call the methods as given the question.
- Stop
Step by step
Solved in 4 steps with 2 images