Example, let's say from a game:
public class Enemy {
protected int x, y;
protected int width, height;
protected int hitpoints;
protected int speed;
}
I want to have multiple classes extending this one (one for every enemy type) but I need to make sure (preferably force this) somehow that the extending class assigns values to all of these variables.
I don't want to pass them through a constructor call or set them in it - so currently I'm forced to do this by simply copying the entire decelerations into every class and assigning them values in the same line.
Is there perhaps a more efficient way to do this? (Sorry if the question is somewhat vague..)
Thanks in advance.
Edit - This is how I would create an extending class:
public class Skeleton extends Enemy {
protected int x, y;
protected int width, height;
protected int hitpoints;
protected int speed;
}