Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I think you've got plenty great and actually-useful answers to your question, so I'm gonna overthink it for a sec. You've already figured out that this is a "has-a" situation, so we can lean into that. I submit that you have a "RobotPart" class with the method "Register", meant to return a hash table of functions and names. You have a "RobotDelegate" class that collects all of these parts, registers them all, and houses the combined hash tables.

Unfortunately I have to go and can't type out a demo of what I'm thinking, but hopefully I got the point across. Some things to thing about:

  • Do you want parts to call for other parts? (e.g. a hand asking a foot to move to a new place).
  • Do you want parts to have their own parts? (e.g. arms have hands, hands have fingers).
  • How will you make more complex actions. If, for instance, you want to make a "go get" function that walks to somewhere and then picks something. You might need a "RobotController" class to coordinate between different parts
  • Does this body had cardinality? you might need placement on the body

In reply to Re: How to sub class-es by JediMasterT
in thread How to sub class-es by exilepanda

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2024-04-25 22:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found