class Pair{ private int x; private int y; Pair(){x = y = 0;} Pair(int x, int y){ this.x = x; this.y = y; } public String toString() { return "(" + x + ", " + y + ")"; } int distanceToOrigin(){ return this.x + this.y; } int distanceBetween(Pair other){ return Math.abs(this.x - other.x) + Math.abs(this.y- other.y); } Pair reflect(){ Pair t = new Pair(); t.x = this.y; t.y = this.x; return t; } void reflectMe(){ int t = this.x; this.x = this.y; this.y = t; } } public class PairClient{ public static void main(String[] args) { Pair p1 = new Pair(1, 2); System.out.println(p1.toString()); System.out.println(p1.distanceToOrigin()); Pair p2 = new Pair(3, 4); System.out.println(p2.toString()); System.out.println(p2.distanceToOrigin()); System.out.println(p2.distanceBetween(p1)); p2 = p1.reflect(); System.out.println(p2); p1.reflectMe(); System.out.println(p1); } }