You'll notice that Laura likes to make all body parts variables. This gives her the freedom to change their values later in the story. It is her well-known propensity for gore that has drawn so many readers to Laura's particular brand of Western. You'll note that she left the sex, name, horse name, and whiskey preference unspecified. Just so all of her humans don't look identical, Laura prefers to specify those variables when she writes the plot.
Humans
have a certain number of legs
have a certain number of arms
have a certain number of eyes
have a certain number of noses
have a certain number of mouths
have a name
have a certain sex
have a horse with a name
have a strong preference in whiskey
A standard human would start with
two legs
two arms
two eyes
one nose
one mouth
When someone asks for your name
tell them your name
You, being as sharp as you are, notice that Laura's human has some interactivity. She can ask its name, and it will respond. This is called a method and is your key to a good time. We'll get to it in just a few pages.
public class Humans
{
int legs;
int arms;
int eyes;
int nose;
int mouth;
String name;
String sex;
String horseName;
String whiskeyPreference;
public Humans()
{
legs = 2;
arms = 2;
eyes = 2;
nose = 1;
mouth = 1;
}
public String whatIsYourName()
{
return name;
}
}
|