Java OOP GUIDE / WORK BADGUY SUPERCLASS Topics
TASK –
PART 1 – SETUP & EXAMINATION – THE BADGUY CLASS Copy
and paste the following BadGuy and BadGuyTester classes.
Examine them to make sure you understand how they work.
TASK –
PART 2 – EXTENDING BADGUY The
BadGuy class creates a very generic BadGuy object. We
now want to create a more specific type of bad guy class that has all of the
features and characteristics of the generic BadGuy.
Create
a Goomba class!
Here
are the specifications for the class: ·
It
inherits from the BadGuy class. (You need to use the extends keyword on the
class header line to do this). ·
It
has these four instance variables (plus the ones in BadGuy): o public int teeth; o public int damage; o public boolean
stompable; o public String colour; ·
It
has a constructor that gets a parameter for name and colour. Teeth are set to two (always), damage is
set to 1, stompable is set to true. Remember that the first line of the
constructor should call the superconstructor. ·
It
has its own toString method that returns “This badguy is a fungi!” (very funny stuff) TASK –
PART 3 – TESTING GOOMBA Inside
BadGuyTester, create a Goomba
and test all of the methods and instance variables. |
||
|