A very common use of a class variable is as a total counter, the total number of some set of things in a class.
As an example, if you had a Java program that could have a variable number of copies of some object, say classes representing CDs and cassette tapes. The class that you define as a pattern for creating instances of CD objects will probably need a field to keep count of the total number of CDs you have. This count field should be a class variable - one that would exist only once in the program.
Let's say you have fifty CDs - you wouldn't want every CD object to have a field in it that contains the total number of CDs in your collection. If they did, when you got your 51st CD, you would have to change the field in 50 other CD objects!
In jLogo, comments start with a semicolon character (";") - that is not part of a word or in a sentence - and continue through the end of the line.
Java compilers have two ways to add comments to your code. One style of comment starts with two slash characters in a row ("//") and continues through the end of the line. A second style of comment, called a multi-line comment, starts with a slash character followed imediately by an asterisk ("/*") and ends with an asterisk followed immediately by a slash ("*/"). These character sequences, as well as all of the characters in between are ignored by the Java compiler.
Java has built-in support for concatenation of Strings, e.g., "asdfg" + "hjkl" which results in a single String: "asdfghjkl"
Use of the plus sign operator to do this makes sense; it's similar to its use to add two numbers together.
But, TurtleGraphics hides a lot of complexity from you, the programmer. It sits on top of a bunch of pixels (picture elements) in what appears to be a two dimensional array. When TurtleGraphics turns the pixels on, by giving them color, we can see them on the display.
Each pixel has an address: think of it as a column number and a row number on a piece of graph paper. Instead of calling one the column number, we say it has some X value. The row number is called the Y value. An X,Y pair of values/numbers is called a coordinate in mathematics. So, our pixel addresses are coordinates. A bit about how the turtle draws is covered in the section: The Turtle's Pen (Raster Graphics).
I've checked and coordinate systems are covered in 7th/8th grade Math books these days. Dig yours up and check it out. It may be in the chapters that cover a "number line" or "signed numbers." In Longfellow's Math Book: Gateways to Algebra and Geometry, published by McDougal, Littel & Company, Chapter 6.8 (Two-Dimensional Graphs) covers a rectangular coordinate system.
Back to Table of Contents