This site requires JavaScript, please enable it in your browser!
Greenfoot back
cxthleen
cxthleen wrote ...

2015/10/19

Need help with picking up and dropping objects

cxthleen cxthleen

2015/10/19

#
Hi! I'm new with programming, and in school we need to do this scenario where a person should be picked up by an ambulance and should be dropped off when the spacebar is pressed. I need help with the code because I'm really confused with this, please?
danpost danpost

2015/10/19

#
A field to hold an Actor type object could be used in the Ambulance class to hold the person picked up and its act method could check for the 'space' key and add the person back into the world.
cxthleen cxthleen

2015/11/2

#
hi, sorry for the late reply! how would i be able to do that?
danpost danpost

2015/11/2

#
If the pick-up and drop-off actions were done instantaneously, then there are only two states for the ambulance -- unoccupied and occupied. If these actions (especially the picking up) take time to accomplish, then there are four states -- unoccupied, loading, occupied and unloading. You will need to keep track of what state the ambulance is in. The actions to be done during each state can be programmed depending on the specific state the ambulance is in.
You need to login to post a reply.