Creating Uruk Hais
From Huben's Wiki
(→Summation) |
(→Fields Of Battle.) |
||
Line 82: | Line 82: | ||
String s = "example string"; | String s = "example string"; | ||
</pre> | </pre> | ||
− | a string object containing the information " | + | a string object containing the information "example string" is created somewhere in computer memory, and the variable 's' is set to that location. Variables storing locations of objects can be called '''pointers''' or '''references'''. We can say they ''point to''' the object or '''refer to''' the object. The type of those variables is the type of their object's class. |
# What does 's' have in it? | # What does 's' have in it? | ||
Line 96: | Line 96: | ||
Look at UrukHai. | Look at UrukHai. | ||
− | # | + | # Which are the instance variables? |
− | # | + | # Which are the class variables? |
# How can you tell class variables from instance variables? | # How can you tell class variables from instance variables? | ||
# When I create an UrukHai object, what variables will be in it? | # When I create an UrukHai object, what variables will be in it? | ||
Line 164: | Line 164: | ||
# Set the new instance variable in Saruman.main() for each of the two instances. | # Set the new instance variable in Saruman.main() for each of the two instances. | ||
# Change the declaim method to show the new instance variable also. | # Change the declaim method to show the new instance variable also. | ||
+ | # Create a third UrukHai, set all its variables, and have it declaim(). Please type everything, no cutting or pasting. |