1.7 KiB
1.7 KiB
Hints
1. Create the Alien Class
- Remember that
object methodsare always passedselfas the first parameter. - Remember the double underscores on both sides of
__init__(). - Instance variables are unique to the
classinstance (object) that possesses them. - Class variables are the same across all instances of a
class.
2. The hit Method
- Remember that
object methodsare always passedselfas the first parameter. - You can choose to allow the Alien's health to fall below zero, or require that it does not.
3. The is_alive Method
- Remember that
object methodsare always passedselfas the first parameter. - 0 may not be the only 'dead' condition, depending on how
hit()is implemented.
4. The teleport Method
- Remember that
object methodsare always passedselfas the first parameter. - Instance attributes can be updated from a method by using
self.<attribute>=<new attribute value>.
5. The collision_detection Method
- Remember that
object methodsare always passedselfas the first parameter. - This method seems like an excellent place to use some kind of placeholder…
6. Alien Counter
- Class attributes are the same across all instances of a
class. - Ideally, this counter would increment whenever someone made an new Alien.
- Class attributes can be changed from an instance method by using the class name:
Alien.<class attribute name>. __init__()is considered an instance method since it initializes a new object.
7. Object Creation
- A
tuplewould be a single parameter. - The Alien constructor takes 2 parameters.
- Unpacking what is inside the tuple would yield two parameters.
- The standalone function is outside of the
class