Please answer this in python. It is creating methods. Add the following four methods to your Crew class: move(self, location): This takes in a location as a string, along with self, and attempts to move the crew member to the specified location. If location is one of the five valid location options ("Bridge", "Medbay", "Engine", "Lasers", or "Sleep Pods"), then this should change self.location to that new value. Otherwise, the function should print out the message: Not a valid location. repair(self, ship): first_aid(self, ship): fire_lasers(self, ship, target_ship, target_location): The above three methods represent tasks that a ba
Please answer this in python. It is creating methods.
Add the following four methods to your Crew class:
- move(self, location):
- This takes in a location as a string, along with self, and attempts to move the crew member to the specified location. If location is one of the five valid location options ("Bridge", "Medbay", "Engine", "Lasers", or "Sleep Pods"), then this should change self.location to that new value.
- Otherwise, the function should print out the message:
Not a valid location.
- repair(self, ship):
- first_aid(self, ship):
- fire_lasers(self, ship, target_ship, target_location):
- The above three methods represent tasks that a basic Crew member is not capable of (but one of its derived classes will be able to accomplish). So each of them should simply print out a message of the form:
<Name> doesn't know how to do that.
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.
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}
crew1.move('Dungeon') #Not a valid location.
print(crew1.location) #Sleep Pods
crew1.move('Engine')
print(crew1.location) #Engine
crew2.repair(space_boat) #Jina doesn't know how to do that.
crew3.first_aid(space_boat) #Daniel doesn't know how to do that.
crew2.fire_lasers(space_boat, space_boat, "Engine") #Jina doesn't know how to do that.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images