Please answer in python Before we start looking at some of the more interesting methods for Crew and its subclasses, we need a class to represent the spaceship that the crew members are interacting with. For now, we’ll just set up the constructor for the Starship class. Constructor: The Starship class constructor should have the following signature: __init__(self, name, crew_list) Where name (the name of the ship) is a string, and crew_list is a list of the Crew objects (or its subclasses) that make up the crew of the ship. The constructor should create instance variables to store the value of the arguments (self.name and self.crew_list respectively), along with one more instance variable: self.damaged, a dictionary with string keys and boolean values representing whether each area of the ship is currently damaged. This should be initialized to: {'Bridge':False, 'Medbay':False, 'Engine':False, 'Lasers':False, 'Sleep Pods':False} Examples: Copy the following if __name__ == "__main__" block into your hw12.py file, and comment out tests for parts of the class you haven’t implemented yet. The lines that have output include the expected value next to them as a comment: if __name__ == '__main__': crew1 = Crew('Sakshi') crew2 = Crew('Jina') crew3 = Crew('Daniel') space_boat = Starship('Ebon Hawk', [crew1, crew2, crew3]) print(space_boat.name) #Ebon Hawk print(space_boat.crew_list) #[Sakshi : Active, at Sleep Pods, Jina : Active, at Sleep Pods, Daniel : Active, at Sleep Pods] print(space_boat.damaged) #{'Bridge': False, 'Medbay': False, 'Engine': False, 'Lasers': False, 'Sleep Pods': False}
Please answer in python
Before we start looking at some of the more interesting methods for Crew and its subclasses, we need a class to represent the spaceship that the crew members are interacting with. For now, we’ll just set up the constructor for the Starship class.
- Constructor: The Starship class constructor should have the following signature:
__init__(self, name, crew_list)
Where name (the name of the ship) is a string, and crew_list is a list of the Crew objects (or its subclasses) that make up the crew of the ship. The constructor should create instance variables to store the value of the arguments (self.name and self.crew_list respectively), along with one more instance variable:
- self.damaged, a dictionary with string keys and boolean values representing whether each area of the ship is currently damaged. This should be initialized to:
{'Bridge':False, 'Medbay':False, 'Engine':False,
'Lasers':False, 'Sleep Pods':False}
Examples:
Copy the following if __name__ == "__main__" block into your hw12.py file, and comment out tests for parts of the class you haven’t implemented yet. The lines that have output include the expected value next to them as a comment:
if __name__ == '__main__':
crew1 = Crew('Sakshi')
crew2 = Crew('Jina')
crew3 = Crew('Daniel')
space_boat = Starship('Ebon Hawk', [crew1, crew2, crew3])
print(space_boat.name) #Ebon Hawk
print(space_boat.crew_list) #[Sakshi : Active, at Sleep Pods, Jina : Active, at Sleep Pods, Daniel : Active, at Sleep Pods]
print(space_boat.damaged) #{'Bridge': False, 'Medbay': False, 'Engine': False, 'Lasers': False, 'Sleep Pods': False}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images