J
Jonathan Bartlett
A few things:
If name and price are the ONLY things changing, it seems silly to make
multiple classes. Just have one class, Weapon.
w = new Weapon("Rifle", 20);
If you have other variance that would really call for inheritance, it is
best to keep the implementation in the subclasses.
For example, if later you decided that price would be based on more than
just the class, and more than just a single variable (like pricing based
on some sort of formula), then your "price" integer becomes wasted
baggage in your new class.
For as long as possible, you should put delay putting actual variables
in base classes.
Jon
If name and price are the ONLY things changing, it seems silly to make
multiple classes. Just have one class, Weapon.
w = new Weapon("Rifle", 20);
If you have other variance that would really call for inheritance, it is
best to keep the implementation in the subclasses.
For example, if later you decided that price would be based on more than
just the class, and more than just a single variable (like pricing based
on some sort of formula), then your "price" integer becomes wasted
baggage in your new class.
For as long as possible, you should put delay putting actual variables
in base classes.
Jon