Now, the villains in Laura's stories are famous for being able to
hold their liquor. Hence, it's very difficult for an onlooker to gauge
how drunk one of her villains really is. Laura decides that it's a good
idea to allow her villain to state how drunk he is, so, she writes a
new method:
If someone asks a villain how drunk he is, the villain
will always respond with his level of drunkenness.
howDrunkAmI
tell them how drunk I am -------------------------------------------------------------------------------------------------
public int howDrunkAmI()
{
return drunkenness;
}
If you're wondering about that "int" in front of the "howDrunkAmI()", Laura had to put that in becuase this method has a return value. In order to let the editor know what sort of value was being returned, she specified "int" (for integer) in front of the name of the method. Remember, her editor doesn't like surprises, and if she didn't tell him what sort of variable this method was going to return, he'd get all hot and flustered. (Now, we don't want that, do we?)
At this point Laura is pretty proud of herself, having created a villain that can experience pretty much the full range of villainous activities. However, just to make for a good closing, Laura decides to have the villain have the ability to tie up a damsel. She sets out to write one more method. What makes this different than her other methods is that it needs information about someone other that the villain, namely the damsel to be tied up. To allow for flexibility (and for a variety of damsels), Laura decides to leave the identity of the damsel blank for now.
If the villain is supposed to tie up a damsel,
tie up the specified damsel, then add one to
the number of damsels he has tied up. Then
print out "Oh my gosh! (the specified damsel)
has been tied up!"
So now you can see the flexibility that Laura has in writing her stories; she can leave certain things to be specified only when the plot is written. And by writing that the damsel will have a name, but not stating what it will be, that's just what she has done. She has also used a print statement that will print out the information gathered by the method as an event in her book. How easy! |