I put the code in the description of the linked (closed) PR, and I’ll paste it again here. (I prepared a PR before reading the docs indicating they would be auto-closed, so I published it anyway, since I already had it ready to go.)
"""Solution to Ellen's Alien Game exercise."""
class Alien:
"""Create an Alien object with location x_coordinate and y_coordinate.
Attributes
----------
(class)total_aliens_created: int
x_coordinate: int - Position on the x-axis.
y_coordinate: int - Position on the y-axis.
health: int - Number of health points.
Methods
-------
hit(): Decrement Alien health by one point.
is_alive(): Return a boolean for if Alien is alive (if health is > 0).
teleport(new_x_coordinate, new_y_coordinate): Move Alien object to new coordinates.
collision_detection(other): Implementation TBD.
"""
total_aliens_created = 0
def __init__(self, x_coordinate, y_coordinate):
Alien.total_aliens_created += 1
self.x_coordinate = x_coordinate
self.y_coordinate = y_coordinate
self.health = 3
def collision_detection(self, x):
pass
def hit(self):
self.health -= 1
def teleport(self, x, y):
self.x_coordinate = x
self.y_coordinate = y
def is_alive(self):
return self.health > 0
#TODO: create the new_aliens_collection() function below to call your Alien class with a list of coordinates.
def new_aliens_collection(x):
return []