java - Change a class constructor depending on other parameters -


i doing uml diagram java application, , came across following doubt:

i have class called information, attributes depends on kind of node is.

for example:

if node = trafficlight, information contain color of light.
if node = signal, contain maximum speed.

how can implement that, both in uml , code?


thank answers, try of them , post solution!

i'm going assume node child of information object. in case, need object each of possible outcomes node be. best way can explain is...

package.name.node   |   |_package.name.node.information      |      |_information.trafficlight(string color)      |      |      |_information.signal(double speed) 

i hope helps. keep in mind i've not programmed in java in long while happened across , remembered doing similar in college ^_^; since it's uml should able idea of go project his, assuming i'm not making fool of myself. said, trying help.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -