Why is it that this method returns true? I'm supposed to write an equals method that returns true if both rectangles are similar (My assumption of a "similar rectangle" is one which has the same ratio of height:length as the other rectangle).
public class Rectangle { public int width; public int length; public Rectangle(int width, int length){ this.width = width; this.length = length; } public static void main(String[] args) { Rectangle r = new Rectangle(2,4); Rectangle s = new Rectangle(6,13); boolean n = s.equals(r); System.out.println(n); } public boolean equals(Rectangle rectangle){ if((this.width / this.length) == (rectangle.width / rectangle.length)) return true; else return false; }
Shouldnt s.equals(r) return false?