Home World Forum
Stars! AutoHost web forums

Jump to Stars! AutoHost


 
 
Home » Stars! Clones, Extensions, Modding » FreeStars » Design Delimma
Design Delimma Fri, 13 June 2003 15:26 Go to previous message
LEit is currently offline LEit

 
Lt. Commander

Messages: 879
Registered: April 2003
Location: CT
I've got an OO design delimma, if anyone can help, I'd appreciate it.

I'm trying to design a Ship class that is composed of a collection of Components.
Each component can be of a certain type (armor, shield, weapon, and several others). Some components can have capabilities of more then one type (armor with some shielding). So far it's pretty easy, use inheritance for the types, and multiple inheritance for the multiple type components.

The complication is that I'd like to be able to read a file of components:
Croby Sharmor, type shield, (generic details, cost, mass, etc), shield strength 65, armor strength 60.

Most shields don't have armor, this one is special. There are some components that have 5 or more sub capabilities, and I'd even like to leave that open, so defining a class for each possible combination is impractical. I want to read a file and make a list of components from that file.

Two options I've considered are:
Make Component class generic enough to handle every combination (put shield and armor and all other variables into it) and have it return some default value if a particular component isn't defined.

The other idea is have Component have a list of Capabilities, and you add to the list as needed. Then you can ask a Component to give you the Armor Capability. This is what I'm currently leaning toward, I feel it's a better design, however, it'll be slightly harder to code.


[Updated on: Thu, 19 June 2003 11:20]




- LEit

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message icon5.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Just how flexible?
Next Topic: Planet Transfer
Goto Forum:
  


Current Time: Thu May 09 23:24:30 EDT 2024