Java bootcamp exercise for classes, subclasses, constructors, and calling methods.
- Super class
Monster
constructs a Monster with argumentString name
and a single methodattack()
. - Child classes
FireMonster
,WaterMonster
, andStoneMonster
extend the class and add a more specialized message to theattack()
method. Runnable.java
declares new instances of objects with each Monster subclass, and runs attacks for each.
run Runnable.java
output:
Attack with fire!
Attack with stones!
Attack with stones!
Attack with stones!
!^_&^$@+%$* I don't know how to attack