Steps:
In your special thing
1. In your special thing: Add a new CONSTRUCTOR. You can have more than one constructor in an object. You must use a constructor that will add a Thing directly to a Robot's backpack- we haven't used this one before. Check the Thing documentation or look at the picture below to see which constructor to set up. Remember your constructor is for your special thing NOT a Thing
Click image for detailed information on this method.
 |
You must add this second constructor to your special Thing. 
Add these THREE lines of code IN the constructor:
- Follow the pattern of previous constructors and call "super" with the ONE parameter sent to the method.
Set the attributes of your special thing:
- Add the special icon to your special thing (set the icon size between 0.5 and 0.8; and
- set the special thing so you can carry it (check the documentation for the method that does this).
In your robot (Santa, Snoopy)
1. In the robot: Use the special robot constructor that gives a robot a certain number of items in its backpack. You used this version of the constructor in Exercise #5, where you created the Robots that sent the message to the Space Station. (Note: you can have more than one constructor in a robot.)
Click image for detailed information on this method.
 |
2. In the robot: Override the makeThing() method.
Click image for detailed information on this method.
 |
This method is used by the robot to add things to its backpack when the "held by" constructor is used. It puts the normal Thing into the backpack.
You can OVERRIDE the method so it will add your version of the Thing (e.g. ones made to look like a present) to the backpack.
First point: this method used a special visibility called protected. Don't worry about that, just leave the top line of the method as is, with protected visibility and having it return a Thing (don't change the return type to your special Thing).

Next, do these TWO things IN the makeThing method:
- Create one of your special Things using the "held by" constructor.
e.g. SpecialThing x = new SpecialThing (....
) // inside the brackets, put the word used to represent the robot
- Return the special Thing. (All methods that have a type MUST return the "answer", in this case the answer is your newly created special Thing.) HINT: What is the name of the special Thing? That name represents the item to return.
e.g. return nameOfSpecialThing ;
|