Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: How to sub class-es

by JediMasterT (Sexton)
on May 21, 2020 at 12:39 UTC ( [id://11117029]=note: print w/replies, xml ) Need Help??


in reply to How to sub class-es

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11117029]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-26 02:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found