You could have something like,
public class Point {
private int px;
private int py;
public Point(int x, int y) {
px = x;
py = y;
}
public int getX() {
return px;
}
public int getY() {
return py;
}
public Point midpoint(Point p2) {
// calculate midpoint
// return point
}
}
However, since you have the slope and intersections, it could be sufficient (in this case, I'm not saying this is good) to return only the mid-y value from midpoint (or mid-x respectively). Then the other variable could be calculated since it's a linear combination.
This post has been edited by Gloin: 28 January 2009 - 08:12 AM

New Topic/Question
Reply





MultiQuote




|