import java.io.PrintWriter; public class Cell { int x; public Cell(int x) { this.x = x; } // Cell(int) public String toString() { return "" + this.x; } // toString() /* public boolean equals(Cell other) { return (this.x == other.x); } // equals(?) */ public boolean equals(Object other) { return this.toString().equals(other.toString()); } // equals public static void main(String[] args) { PrintWriter pen = new PrintWriter(System.out, true); Cell c1 = new Cell(1); Cell c01 = new Cell(1); Cell c2 = new Cell(2); pen.println(c1.equals(c1)); // true, would like true pen.println(c1.equals(c01)); // false, would like true pen.println(c1.equals(c2)); // false, would like false pen.println(c1.equals("1")); // false, would like false (new defn: pen.println("1".equals(c1)); // false, would like false pen.println("1".equals(c1.toString())); // ??? } // main } // class Cell