You need a getter for your String color
attribute in Circle
class, then use it as you are already doing with radius
and area
.
Apart of that, I would recommend you creating setters for the fields in Circle
class in order to change the values of the attributes per instance.
(No code will be given since this is a homework).
In the strange case you don't want to use any getter/setter at all (which is really odd in real world applications), you may change the modifier of your attributes to enable access to them directly from other classes. Here's the Java modifier access level:
Modifier Class Package Subclass World
public Y Y Y Y
protected Y Y Y N
no modifier Y Y N N
private Y N N N
So, you may change String color
from private
to public
and any class can access to this attribute and use it or change its value with no problems. Note that by doing this you break encapsulation of your class.
More info: