Not too sure what the parameters of the methods 'calculate', 'volme' are for?
If you're looking to override the default toString method, so when you call System.out.println(new Box(1,2,3)): it prints out the volume, and value calculate returns for the box then the following should work:
Box b = new Box(1,2,3);
System.out.println(b);
Then the following should work:
@Override
public String toString()
{
return "Volume: " + volume(0.0) + ", calculate: " + calculate(0.0);
}
This would print the volume and whatever calculate returns, both clearly labelled.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…