PDA

View Full Version : Java Application


cycloner93
Nov 16, 2013, 09:10 AM
How to do this?

Design a java class named MyPoint to represent a point with x- and y-coordinates. The class contains:
Two data fields x and y that represent the x- and y-coordinates.
A no-argument constructor that creates a point (0, 0).
A constructor that constructs a point with specified coordinates.
Two get methods for data fields x and y, respectively.
A method named distance that returns the distance from this point to another point of MyPoint type.
A method named distance that returns the distance from this point to another point of MyPoint with specified x- and y-coordinates.
toString method that displays the coordinate of x and y.

Curlyben
Nov 16, 2013, 09:14 AM
What do YOU think ?
While we're happy to HELP we wont do all the work for you.
Show us what you have done and where you are having problems..

cycloner93
Nov 16, 2013, 09:25 AM
I am sorry I am really very bad in coding -.-" This is only what I did.

class MyPoint {

int x,y;

}

MyPoint() {
x=0;
y=0;
}

int getX() {
return x;
}

int getY() {
return y;
}

cycloner93
Nov 16, 2013, 09:36 AM
What do YOU think ?
While we're happy to HELP we wont do all the work for you.
Show us what you have done and where you are having problems..

I am sorry I am really very bad in coding -.-" This is only what I did.

class MyPoint {

int x,y;

}

MyPoint() {
x=0;
y=0;
}

int getX() {
return x;
}

int getY() {
return y;
}