Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean equals(Shape otherObject) {
- // ensure not null
- if (otherObject == null) {
- return false;
- }
- // check identity
- if (this == otherObject) {
- return true;
- }
- // @todo: check if other object is the same type, return false if not
- if (this.getType().equals(otherObject.getType())) {
- return true;
- }else return false;
- // @todo: check area, return false if not equal
- if (this.getArea() == otherObject.getArea()) {
- return true;
- }
- // @todo: if you want to confirm dimensions are equal, need branch based on shape type first
- // as different _types_ of shapes have different dimensions, but this is depending on if you want
- // to decide that length != width, such that a rectangle of w=5, l=8 is unequal to l=5, w=8
- if (this.getType().equals("Circle") && (this.getRadius() == (otherObject.getRadius()))) {
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement