At this point Eunice 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, Eunice 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), Eunice 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 Eunice 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!
I have nothing to say to you people. If you feel bad about understanding everything so far, then you can read the red section for this one.
"Geez! I should have stayed with the green type," you're probably saying to yourself. Don't worry. It looks much worse than it is, and you probably understand most of it already. First, we have the name of the method: "tieUpDamsel". No surprise there. Then, between those parentheses, we have "Humans damsel". What comes between those parentheses is called an argument. It helps make the method more specific. When Eunice starts writing her plot, she will at some point want her villain to tie up a damsel (what sort of Western would it be without it?). But if she just writes in her plot, "villain.tieUpDamsel()", that wouldn't be very exciting for the reader. Who has been tied up? What is her name? Priding herself on always having strong female characters, Eunice wants to add the name of the damsel who is being tied up. Hence, when her plot says "tieUpDamsel", it will also say the name of the damsel being tied up as an argument. "Humans", which comes before "damsel", tells her editor that the thing being tied up is a human. Her editor doesn't like surprises, so that knowing that it is a human being tied up, rather than say, a sheep, reduces the amount of guesswork on his end.
The next line is another attempt by Eunice to please her rather persnickety editor, who is even more picky than she is! Even though she has supplied the name of the damsel as an argument, her editor won't let her use it in the method until she has stated that the "damsel" that she declared as a "Villains" variable is equal to the value given in the method's argument.
Having finally jumped through all of her editor's hoops (don't expect to understand all of that right away, it took Eunice a couple of weeks!), Eunice gets down to finishing the rest of her method. Once the villain has tied up a damsel, the variable "tiedUpDamsels" will surely go up by one, so Eunice puts the same "++" after tiedUpDamsels that she had put after "drunkenness" in the drinkWhiskey" example.
The stage being set, Eunice decides that it is time to let her readers know what is going on. Hence, the "System.out.println" statement. A bit wordy, but it let's her editor know that what comes between those parentheses goes into the final text of the book: all the text she puts in between quotation marks. Why is the variable 'damsel.whatIsYourName' then not in quotation marks? Because it is not a literal, but rather an object's method. By keeping it out of the quotation marks, Eunice lets her editor know that he has to go look for the damsel object (he would find out that it was of the "Humans" class) then for the method "whatIsYourName" (he would see that it returned the damsel's name). All of that for a damsel's name!
Had she put damsel.whatIsYourName inside of the quotation marks, her editor would have printed out in the final copy of the book : "The villain has tied up + damsel.whatIsYourName!". No Pulitzers for that. In order for her editor to substitute the variable name for the word name, Eunice closes the quotation marks before she writes it. The plus "+" lets her editor know that she wants to join the two statements.
Lucky for you, the next page is just review.