So now we've sneaked a peak at one of Eunice's binders. She has reviewed the Western Town section and thinks that this western should take place in, not surprisingly, a Western Town. So she's ready to write the first part of her plot. Eunice turns to the main paper that is sitting in the middle of her desk and starts to write the story.


      The Gunfight at the Old West Saloon
      This story takes place in a Western town called Sweaty Post. Sweaty Post has one sheriff, two saloons, and five troublemakers.

      Just a couple lines, but Eunice has, in fact, said quite a bit. When she sends the story to her editor, he will look up "Western Town" in the binders she sends along and fill in the date, location, and number of stables. In addition, Eunice has added information about the sheriff, saloons and troublemakers. But that's okay, because her editor was expecting it. Because her binder stated that every western town would have a certain number of these, but didn't say how many, her editor was quite happy to see them specified in her plot. Even though her main plot page only has two lines, because of the reference to her binder, her story already contains quite a bit of information.




      Main Gunfight
        Western Town sweatyPost is a new Western Town.
          the number of saloons in sweatyPost is two.
          the number of sheriffs is one.
          the number of troublemakers is five.

      Eunice takes two very important steps early on in her plot. First, she instantiates an object of type WesternTown. Having created her first object, Eunice then goes on to fill out the information that was initially lacking in the WesternTown class: (number of saloons, sheriffs, troublemakers)




      public class Gunfight {
        public static void main (String arguments[]) {
        WesternTown sweatyPost = new WesternTown;
        sweatyPost.saloons = 2;
        sweatyPost.sheriffs = 1;
        sweatyPost.troublemakers = 5;
        }

      }

      Eunice sure has a strange way of saying things, doesn't she? It would be possible to explain what each word in those first two lines does, but it wouldn't make much sense to you at this point, and it would really tax my small brain, so let's skip it for now, eh? What's important to know is that that line is how Eunice let's her editor know that this piece of paper is her main routine, or plot.

      When she decides to specify those variables (saloons, etc) that were not specified in the WesternTown class, Eunice first states the name of the object (in this case, sweatyPost. Remember that sweatyPost is an object of WesternTown) followed by a period and then by the name of the variable. Having done this, Eunice can then provide a value for the variable, such as two.




      So, believe it or not, you've just seen object-oriented programming in action. Our author Eunice first created a class (that was the binder) that roughly described a Western Town, then turned to her main plot page and created (instantiated) a western town object, which she then called sweatyPost.