/* * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template */ package shape; /** * * @author gicorada */ public class Rectangle extends Shape { private int x, y, w, h; public Rectangle(int x, int y, int w, int h) { this.x = x; this.y = y; this.w = w; this.h = h; } @Override public int width() { return w; } @Override public int height() { return h; } @Override public int posX() { return x; } @Override public int posY() { return y; } @Override public int hashCode() { int hash = 5; hash = 37 * hash + this.x; hash = 37 * hash + this.y; hash = 37 * hash + this.w; hash = 37 * hash + this.h; return hash; } @Override public boolean equals(Object o) { if (o == null) return false; if (getClass() != o.getClass()) return false; Rectangle r = (Rectangle) o; return w == r.w && h == r.h && x == r.x && y == r.y; } }