Reputation: 323
I have an abstract class, Entity.java. I also have a class TransportUnit.java that extends the Entity class. Entities are to be constructed with a String name and int lifePoints. Transport Units are to be constructed with the same and in addition an empty Set. My question is how to write the constructor for the TransportUnit class and why? Thanks in advance.
Upvotes: 0
Views: 71
Reputation: 35598
You would write it more or less the same way as a normal constructor, just calling super()
Set s;
public TransportUnit(String name, int lifePoints){
super(name, lifePoints);
s = new HashSet(); //or other type of set
}
Upvotes: 2