Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class point
- {
- private int x;
- private int y;
- private double a;
- private double b;
- //constructs a new point with (0,0) as coordinates
- public point()
- {
- x=0;
- y=0;
- }
- //constructs a new point with the given (x,y) location
- public point(int initialX, int initialY)
- {
- x = initialX;
- y = initialY;
- }
- //constructs a new point with coordinates of type double
- public point(double initialX, double initialY)
- {
- if((initialX-(int) initialX)>0.5)
- a=(int)initialX + 1;
- if((initialY-(int) initialY)>0.5)
- b=(int)initialY + 1;
- }
- //returns the x-coordinate of this point
- int getX()
- {
- return x;
- }
- //returns the y-coordinate of this point
- public int getY()
- {
- return y;
- }
- public String toString()
- {
- return("(" + x + ", " + y + ")");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement