Введение в программирование
Введение в ОО дизайн
Square extends Rectangle
Rectangle extends Square
boolean setWidth(int w)
Square extends Rectangle
setWidth ≡ setSide
Square extends Rectangle
Rectangle setWidth(int w)
Square extends Rectangle
Square extends Rectangle MutableRectangle extends Rectangle MutableSquare extends Square
Square extends SquareOrRectangle Rectangle extends SquareOrRectangle
Square::asRectangle Rectangle::boundingSquare
Square extends Rectangle
public boolean equals(Object o)
class Point { int x, y;
public boolean equals(Object o) { if (o instanceof Point) { Point that = (Point) o; return this.x == that.x && this.y == that.y; } return false; }
public class ColorPoint extends Point { protected int c; public boolean equals(Object o) { if (o instanceof ColorPoint) { ColorPoint that = (ColorPoint) o; return this.x == that.x && this.y == that.y && this.c == that.c; } return false; } }
public class ColorPoint extends Point { protected int c; public boolean equals(Object o) { if (o instanceof ColorPoint) { ColorPoint that = (ColorPoint) o; return this.x == that.x && this.y == that.y && this.c == that.c; } return super.equals(o); } }