Re: Creating a Point.class
Have you looked at the java SE's Point class? The name Point is used by the Java SE. Using the same name will cause confusion.
What have you tried?
Re: Creating a Point.class
Hey Norm,
I was unaware of this, but my teacher specifically asked us to label the new class "Point". Here is what I have gotten so far
public class Point {
private int x, y;
public Point(int x, int y) {
}
public int getX() {
return x;
}
public int getY() {
return y;
}
}
So I have my instance data, constructor, but am not sure of how to tie in x,y data to the getX and setXY. I know it is not much of a start and probably contains some errors, but I am at a dead end. And sorry about the vagueness of the first post. I am not looking for you to write my code for me. I just need some direction. Thanks for your time. -Jon
Re: Creating a Point.class
The constructor needs to save the x,y values it receives.
The get method should return the current value of the variable. Yours look OK.
setXY() would be similar to the constructor: save x and y
When you post code, please wrap your code with
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
Re: Creating a Point.class
Thanks, that helped a lot. I am now stuck on the setXY() section and was wondering how setXY() works? Do you need user input and use the Scanner class? -Jon
Re: Creating a Point.class
Ask your teacher what he intended. I suggested that setXY() do the same as the constructor.
Re: Creating a Point.class
Awesome Norm, just finished the program. Thanks for your help. Sorry for my lack of java and forum ettiquette, I am new to the game. -Jon
Re: Creating a Point.class
No problem. I'm sure you'll improve with more experience.