I have two classes that have no methods:
Weapon ---------- String name int cost int requiredStrength int requiredDexterity int minDamage int maxDamage
Armor --------- String name int cost int requiredStrength int defenseRating
First question: is it OK to have a classes like this?
Second question: the variables 'name', 'requiredStrength', and 'cost' are common to both classes. Does it make sense to factor them out into a superclass, like the one below:
Equipable ---------- String name int cost int requiredStrength
third question: is it good practice to have a superclass just for the sake of factoring out common variables? And if so, is it better in this case to use protected access rather than private?


LinkBack URL
About LinkBacks
Reply With Quote
