i creating data system hold variety of items game , not sure organizational style more efficient. example have item class, making subclass of weapon , subclass of melee extends weapon more or less efficient creating several variables in item class holds whether weapon or armor or other , holds if melee or ranged or helmet..etc. or combination of these efficient , organized point flexible manipulate?
the question broad, speaking best make subclasses opposed storing excessive variables in base item.
start bases , work way down.
public class item { private string name; ... } public class weapon extends item { ... } public class melee extends weapon { ... } public class ranged extends weapon { ... } this way can define things like
public class dagger extends melee { ... } and won't have worry defining fields common items, name.
it won't design problem, since game may want @ lightweight java game library if haven't already.
Comments
Post a Comment