Alien exercise
Alien exercise¶
class Alien:
def __init__(self, name):
self.name = name
self.energy = 10
def move(self, distance=1):
if self.energy < steps:
print("I don't have the energy to move that far")
else:
self.energy -= steps
def sleep(self):
self.energy = 10
class MyAlien(Alien): # give your alien a unique name
def __init__(self, name):
super().__init__(name)
# define two more attributes your alien has
# think of a unique way to display your alien's attributes
def __str__(self):
s = 'How should you display your alien?'
return s
# think of two new actions your alien can do
def action1(self):
pass
def action2(self):
pass
# Use this space to initialize and display a new instance of your alien
# have your alien move some distance
# display their new energy level
# have your alien sleep
# display their new energy level
# use this space to have your alien perform the first new action
# did any attributes change?
# use this space to have your alien perform the second new action
# did any attributes change?