Hi everyone,
Im still fairly new to java and i've gotten stuck on a small part of exercise. Could anybody help me? Heres the question relating to this section:
Write a class to encapsulate the notion of a rectangle. A rectangle is represented by two integers representing its length and height, respectively. As well as its instance variables, the class should have instance methods called get() and isSquare(). Method get initialises the instance variables with, respectively, a length and height read from the keyboard. Method isSquare returns a boolean corresponding to whether this rectangle is a square or not. There is no need to write a constructor.
It's probably really simple but i'm just a bit unsure as to what to write in the isSquare method below.
This is what i have so far
public class Rectangle { private int length; private int height; public void get() { System.out.println("Please enter length and height"); int l = Integer.parseInt(Console.readToken()); int h = Integer.parseInt(Console.readToken()); } public static boolean isSquare(Rectangle r) { ??? } }
Any help would be greatly appreciated, thanks