I have this constructor with a function however when i compile my main method i non-static method area cannot be referenced from a static context. I know its a simple fix i just cant quite get there. Thanks
public class Rect{
private double x, y, width, height;
public Rect (double x1, double newY, double newWIDTH, double newHEIGHT){
x = x1;
y = newY;
width = newWIDTH;
height = newHEIGHT;
}
public double area(){
return (double) (height * width);
}
and this main method
public class TestRect{
public static void main(String[] args){
double x = Double.parseDouble(args[0]);
double y = Double.parseDouble(args[1]);
double height = Double.parseDouble(args[2]);
double width = Double.parseDouble(args[3]);
Rect rect = new Rect (x, y, height, width);
double area = Rect.area();
}
}