- 1

Trying to solve the shooting game project

class Enemy: name = "" lives = 0 def __init__(self, name, lives): self.name = name self.lives = lives def hit(self): self.lives -= 1 if self.lives <= 0: print(self.name + ' killed') else: print(self.name + ' has '+ str(self.lives) + ' lives') class Monster(Enemy): def __init__(self): super().__init__('Monster', 3) class Alien(Enemy): def __init__(self): super().__init__('Alien', 5) m = Monster() a = Alien() while True: x = input() if x == 'exit': break Here is my code I don't know the next step to tale from here

26th Mar 2021, 12:19 PM
Simisola Osinowo
Simisola Osinowo - avatar
7 odpowiedzi
+ 3
class Enemy: name = "" lives = 0 def __init__(self, name, lives): self.name = name self.lives = lives def hit(self): self.lives -= 1 if self.lives <= 0: print(self.name + ' killed') else: print(self.name + ' has '+ str(self.lives) + ' lives') class Monster(Enemy): def __init__(self): super().__init__('Monster', 3) def hit(self): super().hit() class Alien(Enemy): def __init__(self): super().__init__('Alien', 5) def hit(self): super().hit() m = Monster() a = Alien() while True: x = input() if x == 'exit': break elif x == 'laser': a.hit() elif x == 'gun': m.hit() https://code.sololearn.com/cheRw6L9neDj/?ref=app
8th May 2021, 8:14 AM
BABULAL SANODIA
+ 1
while True: x = input() if x == 'exit': break elif x == 'laser': a.hit() elif x == 'gun': m.hit()
26th Mar 2021, 1:04 PM
Qusi AL-Hejazi
Qusi AL-Hejazi - avatar
0
Hey, looks fine, what do you want to do next?
26th Mar 2021, 12:49 PM
Luk
Luk - avatar
0
It still did not work it gave eof error
26th Mar 2021, 1:55 PM
Simisola Osinowo
Simisola Osinowo - avatar
0
Luk i want to 2. Complete the while loop that continuously takes the weapon of choice from user input and call the corresponding object's hit() method.
30th Mar 2021, 8:43 AM
Simisola Osinowo
Simisola Osinowo - avatar
0
Hey some one post the correct answer
3rd Apr 2021, 3:27 PM
Yakesh.S
Yakesh.S - avatar
0
Can someone post the right answer of the shooting game, i have been stuck for 2 weeks and nobody posted the right one
12th Sep 2021, 8:32 AM
Makima’s Dog
Makima’s Dog - avatar