33
44class Alien :
55 """
6- Create an Alien object with location x_coordinate and y_coordinate .
6+ Alien located at given coordinates .
77
88 Attributes
99 ----------
@@ -17,37 +17,74 @@ class Alien:
1717 -------
1818 hit(): Decrement Alien health by one point.
1919 is_alive(): Return a boolean for if Alien is alive (if health is > 0).
20- teleport(new_x_coordinate, new_y_coordinate): Move Alien object to new coordinates.
20+ teleport(new_x_coordinate, new_y_coordinate): Move Alien object
21+ to new coordinates.
2122 collision_detection(other): Implementation TBD.
2223 """
2324
2425 total_aliens_created : int = 0
2526
2627 def __init__ (self , x_coordinate : int , y_coordinate : int ):
28+ """
29+ Initialize a new Alien at the provided coordinates.
30+
31+ Sets health to 3, assigns x and y coordinates, and increments
32+ Alien.total_aliens_created.
33+
34+ :param x_coordinate: Position on the x-axis.
35+ :param y_coordinate: Position on the y-axis.
36+ :return: None
37+ """
2738 self .health : int = 3
2839 self .x_coordinate = x_coordinate
2940 self .y_coordinate = y_coordinate
3041 Alien .total_aliens_created += 1
3142
3243 def is_alive (self ):
44+ """
45+ Return whether the alien is alive.
46+
47+ :return: True if health > 0, else False.
48+ """
3349 return self .health > 0
3450
3551 def hit (self ):
52+ """
53+ Decrement the alien's health by one point.
54+
55+ :return: None
56+ """
3657 self .health -= 1
3758
3859 def teleport (self , new_x_coordinate , new_y_coordinate ):
60+ """
61+ Decrement the alien's health by one point.
62+
63+ :return: None
64+ """
3965 self .x_coordinate = new_x_coordinate
4066 self .y_coordinate = new_y_coordinate
4167
4268 def collision_detection (self , other ):
43- pass
69+ """
70+ Determine whether this Alien collides with another.
71+
72+ Implementation TBD; currently returns None.
73+
74+ :param other: Another Alien or object to check for
75+ positional overlap.
76+ :return: None
77+
78+ `Source: /ellens-alien-game/classes_test.py`
79+ """
80+ pass # pylint: disable=unnecessary-pass
4481
4582
4683def new_aliens_collection (
4784 alien_start_positions : list [tuple [int , int ]],
4885) -> list :
4986 """
50- Creates a list of Alien() objects, given a list of positions (as tuples) .
87+ Create a list of Alien objects from starting positions.
5188
5289 :param alien_start_positions: given a list of positions
5390 :return: a list of Alien() objects
0 commit comments