Problem 9 (250pts): Tank Ant
The BodyguardAnt
provides great defense, but they say the best defense is a good offense.
The TankAnt
is a container that protects an ant in its place and also deals 1 damage to all bees in its place each turn.
Like any ContainerAnt
, a TankAnt
allows the ant that it contains to perform its action each turn.
Class | Food Cost | Health | |
---|---|---|---|
![]() | TankAnt | 6 | 2 |
We have not provided you with a class header.
Implement the TankAnt
class from scratch.
Give it a class attribute name
with the value 'Tank'
(so that the graphics work) and a class attribute implemented
with the value True
(so that you can use it in a game).
You should not need to modify any code outside of the TankAnt
class.
If you find yourself needing to make changes elsewhere, look for a way to write your code for the previous question such that it applies not just to BodyguardAnt
and TankAnt
objects, but to container ants in general.
Hint: The only methods you need to override from
TankAnt
's parent class are__init__
andaction
.Hint: Like with
FireAnt
, it is possible that damaging a bee will cause it to be removed from its place.
Before writing any code, unlock the tests to verify your understanding of the question:
$ python ok -q 09 -u
Once you are done unlocking, begin implementing your solution. You can check your correctness with:
$ python ok -q 09
Congratulations! You have finished Phase 2 of this project!