tengtium
Posts: 3
Nickname: tengtium
Registered: Feb, 2003
|
|
Re: I have no idea?
|
Posted: Feb 12, 2003 8:18 AM
|
|
// this is the constructor of the class Point // if initiate an object of type Point // this is automaticaly called // like this // Point myPoint = new Point(10,10);
public Point (int i, int j) { xCoord = i; yCoord = j; }
// this is a method of the class // this means that your class Point // can do this: swap // it does what name implies // swap the properties of the class Point // like this: // myPoint.swap(); public void swap() { int temp = xCoord; temp=xCoord; yCoord= temp; } // this is another method of the class // this means that your class Point // can do this: printIt // it does what name implies // print the value of the properties of the class Point // like this: // myPoint.printIt();
public void printIt() { System.out.printIn("X coordinate = " + xCoord); System.out.printIn("Y coordinate = " + yCoord); }
// this are properties of the class Point private int xCoord; //X Coordinate private int yCoord; //Y Coordinate
}
// this is another constructor of the class Point // if initiate an object of type Point // this is automaticaly called // like this // Point myPoint = new Point();
Public Point () { xCoord = 0; yCoord = 0; }
|
|