M
mohed.haidar
Hello guys, happy new year.
Well, a very basic question. I make a class objekt that lookes
something like this :
public class circle {
public static final PI = 3.14159;
public double r;
public double area(double r) {
return r*r*PI;
}
}
and then from somewhere else I do :
circle.r = 5;
double area = circle.area(); <--- this gives me a compilation error,
it wants me to specify circle.area(5). I thought
that it was legitamet code to leave it at (). Is'nt it what object
oriented code was all about, i have already defined the objects
variable r to bee 5, shouldent need to further specify
circle.area(5).
Thank you for any response in advance.
Well, a very basic question. I make a class objekt that lookes
something like this :
public class circle {
public static final PI = 3.14159;
public double r;
public double area(double r) {
return r*r*PI;
}
}
and then from somewhere else I do :
circle.r = 5;
double area = circle.area(); <--- this gives me a compilation error,
it wants me to specify circle.area(5). I thought
that it was legitamet code to leave it at (). Is'nt it what object
oriented code was all about, i have already defined the objects
variable r to bee 5, shouldent need to further specify
circle.area(5).
Thank you for any response in advance.