O'Reilly logo

Sage Beginner's Guide by Craig Finch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - making the tanks move

To start out, we will define attributes and methods that allow the tank instances to move. Execute this enhanced version of the previous example:

 class Cannon(): """Model of a large cannon.""" def __init__(self, damage): """Create a Cannon instance Arguments: damage Integer that represents the damage inflicted by the cannon """ # _damage amount of damage inflicted by cannon (integer) # _operational True if operational, False if disabled self._damage = damage self._operational = True def __str__(self): return 'Damage value:' + str(self._damage) class Track(): """Model of a continuous track.""" def __init__(self): # _operational True if operational, False if disabled self._operational = True class Turret(): ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required