Alexander
By: a guest | Feb 9th, 2010 | Syntax:
Java | Size: 1.45 KB | Hits: 23 | Expires: Never
{
/** Decleration of variables */
private int Id = 0; // the unique id for the instance of the class
static int counter = 0; // the counter of how many classes made
static List classList
= new List(); // creates new list to store all the class instances
private double coord_x, coord_y;
/**
Description: This constructor will run when new instance of this class is
created and no values for x and u are specified
*/
{
this(0.0,0.0);
}
/**
Description: This constructor will run when new instance of this class is
created and gets specified values for x and y
@param x (double), the value of x coordinate
@param y (double), the value of y coordinate
*/
public Point(double x,
double y
)
{
this.coord_x = x;
this.coord_y = y;
classList.set(this.Id,this); // this is what i am trying to get to work
this.Id = this.counter++;
}
}
// i am trying to keep track of all classes so i can have a method within this class that will print all my x, y and the Id of the class
// My idea was to add the refrence of the class to a list and then use for loop to print them all out.
//Error
Point.
java:47
: cannot find symbol
symbol : variable This
classList.set(this.Id,This);
^
1 error