Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please solve with proper indented block in python dont use any built in function Implement the HogwartsQuidditchSquad class derived from the Squad class with necessary

Please solve with proper indented block in python dont use any built in function

Implement the HogwartsQuidditchSquad class derived from the Squad class with necessary variables and methods so that the expected output is generated. Do not change any given code. [Hint: In order to form a squad, you need at least 5 members. And in order to form a perfect squad you need 2 beaters, 1 seeker, 1 chaser and 1 keeper. ] class Squad: playerCount=0 def __init__(self,name,squadType): self.name = name self.squadType = squadType def formSquad(self): if Squad.playerCount >= 5: return True else: return False def __str__(self): s = f"{self.name} is a {self.squadType} team. " s+= f"Number of players in {self.name} is {Squad.playerCount} " return s #Write your code here f = HogwartsQuidditchSquad("Hogwart's Dragons","Quidditch") f.addPlayer(["Harry Potter","Seeker","Gryffindor"],["Katie Bell","Chaser","Gryffindor"]) print("1.====================================") print(f) print("2.====================================") f.formSquad() print("3.====================================") f.addPlayer(["Vincent Crabbe","Beater","Slytherin"]) f.addPlayer(["Miles Bletchley","Keeper","Slytherin"]) print("4.====================================") print(f) print("5.====================================") f.formSquad() print("6.====================================") f.addPlayer(["Ethan Humberstone","Keeper","Hufflepuff"]) f.formSquad() print("7.====================================") f.addPlayer(["Fred Weasley","Beater","Gryffindor"]) print(f) print("8.====================================") f.formSquad() Output: 1.==================================== Hogwart's Dragons is a Quidditch team. Number of players in Hogwart's Dragons is 2 The Players are: Seeker: Player name: Harry Potter, House: Gryffindor Chaser: Player name: Katie Bell, House: Gryffindor 2.==================================== We do not have enough players to form a squad. 3.==================================== 4.==================================== Hogwart's Dragons is a Quidditch team. Number of players in Hogwart's Dragons is 4 The Players are: Seeker: Player name: Harry Potter, House: Gryffindor Chaser: Player name: Katie Bell, House: Gryffindor Beater: Player name: Vincent Crabbe, House: Slytherin Keeper: Player name: Miles Bletchley, House: Slytherin 5.==================================== We do not have enough players to form a squad. 6.==================================== We have enough players to form a squad. But we cannot form a perfect squad. 7.==================================== Hogwart's Dragons is a Quidditch team. Number of players in Hogwart's Dragons is 6 The Players are: Seeker: Player name: Harry Potter, House: Gryffindor Chaser: Player name: Katie Bell, House: Gryffindor Beater: Player name: Vincent Crabbe, House: Slytherin Player name: Fred Weasley, House: Gryffindor Keeper: Player name: Miles Bletchley, House: Slytherin Player name: Ethan Humberstone, House: Hufflepuff 8.==================================== We have enough players to form a squad. Also we can form a perfect squad!!

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 Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions