This is a dumb question but it\'s been a long time since I\'ve worked with java... How can I write my constructor with Boolean values or should I just write a default construct
A boolean parameter is just like any other type.
So, it would be like this.
public Creature(int startTerrain, boolean flying, boolean magic, boolean charge, boolean ranged, int special){
terrain = startTerrain;
flyingCreature = flying;
magicCreature = magic;
canCharge = charge;
rangedCombat = ranged;
specialAbility = special;
}
If these parameters are going to be always the same on the beggining, then you can set them on a default constructor, as you said.
Since, you have classes inheriting this one, their constructor will have to call super()
, which calls the parent class constructor. If you call it without any parameters, the base constructor of Creature will be called.