Skip to content

Latest commit

 

History

History
42 lines (28 loc) · 1.72 KB

File metadata and controls

42 lines (28 loc) · 1.72 KB

Hints

1. Create the Alien Class

  • Remember that object methods are always passed self as the first parameter.
  • Remember the double underscores on both sides of __init__().
  • Instance variables are unique to the class instance (object) that possesses them.
  • Class variables are the same across all instances of a class.

2. The hit Method

  • Remember that object methods are always passed self as 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 methods are always passed self as the first parameter.
  • 0 may not be the only 'dead' condition, depending on how hit() is implemented.

4. The teleport Method

  • Remember that object methods are always passed self as 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 methods are always passed self as 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 tuple would 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