Jump to content

  • Log In with Google      Sign In   
  • Create Account


[java] Dynamic Objects - Robot Example


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Spyder   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 December 2000 - 12:00 PM

Problem. I have a bunch of robots that have different behaviors, attributes and skills. At the moment all robot types are predefined, but I would really like to assemble a custom robot on the fly.
consider this:
class LargeRobot extends MotherRobot implements Infravision, Flight, Turbo, Kick, Hostile

Next time around I want to create a LargeRobot that doesn''t have Flight but has Dive instead. How do I make this structure more dynamic? Would it be smarter to let LargeRobot have a vector of behaviors, attributes and skills that can shrink and grow? How would a smart java game programmer solve this basic task?

Sponsor:

#2 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 23 December 2000 - 12:13 PM

the design patterns forum has a thread on this very same topic, check all the threads and see if you can find it. They are using spaceships as their example. Or if you are looking for a simple solution just include all the abilities and then have boolean variables for whether they have the ability. Then if the ability is true, the method works normally, otherwise it does nothing.

#3 Spyder   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 December 2000 - 01:38 PM

quote:
Or if you are looking for a simple solution just include all the abilities and then
have boolean variables for whether they have the ability. Then if the ability is true, the method works normally,
otherwise it does nothing.


That would work but it sounds like I''ll end up with 5000 if then statements to check all the boolean variables? And the class will be extremely large and waste memory space if a third of all the functions are not used?






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS