public class Point { /* def __init__(self, x = 0, y = 0): self.x = x #initaizing state self.y = y */ private int x; //visible inside of the class. private int y; public Point(int x, int y) //this is the OBGYN. { this.x = x; //this works like self this.y = y; } /* def __str__(self): #makes string representation of your object return f"({self.x}, {self.y})" */ public String toString() { return String.format("(%s, %s)", x, y); } /* def distance_to(self, other): return math.hypot(self.x - other.x, self.y - other.y) */ public double distanceTo(Point other) { return Math.hypot(this.x - other.x, y - other.y); } /* def reflection_across_x(self): return Point(self.x, -self.y) def reflection_across_y(self): return Point(-self.x, self.y) */ public Point reflectionAcrossX() { return new Point(x, -y); } public Point reflectionAcrossY() { return new Point(-x, y); } public int getX() { return x; } public int getY() { return y; } public static void main(String[] args) { Point p = new Point(3,4); Point q = new Point(0,0); System.out.println(p); System.out.printf("(%s, %s)\n", p.x, p.y); System.out.println(p.distanceTo(q)); System.out.println(q.distanceTo(p)); System.out.println(p.reflectionAcrossX()); System.out.println(p.reflectionAcrossY()); /* p = Point(3,4) print(p) q = Point() print(q) #print(f"({p.x}, {p.y})") print(p.distance_to(q)) print(p.reflection_across_x()) */ } }