First page Back Continue Last page Overview Graphics

Exercise

Extend the robot class with an attribute „build_year“.

Problem:

name and build_year

can be accessed from “outside”!

class Robot:

# like before

def set_build_year(self, by):

self.build_year = by

def get_build_year(self):

return self.build_year

x = Robot("Henry", 2008)

y = Robot()

y.set_name(x.get_name())

print(x.get_name(), x.get_build_year())