|
What two variables do you expect a Point object to have? A good answer might be:A point consists of a pair of numbers, (x, y). | |
Description of a ClassThis is still a little vague. In a mathematics book, a point will be given a precise mathematical definition. For programming, a precise software description of class Point is needed. The Java class libraries come with descriptions of the classes within them. A printed reference for Java will have documentation for Point under the section for the AWT. If you downloaded the JDK documentation from Sun Microsystems, browse through the hypertext index. If you are using a Java development environment like Cafe or J++, type in the word Point in the program editing window, put the cursor over it, and hit the F1 key. You should get documentation similar to the following:
(I've left out some methods we won't be using.) For now, ignore the word "public" in the above. The documentation for a class will show the data it contains (its variables) and the methods you can use to manipulate that data. Also shown are the constructors that are used to create an object of the class. Sometimes (as here) the variables of a class are called "fields." Notice that the two variables are named "x" and "y" and are of type int. | |
QUESTION 3:There are three constructors listed for Point. Each one creates a Point. What is the difference between the constructors? Click Here after you have answered the question |