I have this very long exercise and I came a cross a problem in each sub class.
The problem says and I have no idea what mistake I’ve made while writing.
If you could check the 4 toString methods I would be much apprecaited .
The code is here: http://paste.org/pastebin/view/39488
I know I should past the code here but it is very long and I’m not able to organize it well.
toString() in Shape cannot override toString() in java.lang.Object; attempting to use incompatible return type
toString() in Square cannot override toString() in java.lang.Object; attempting to use incompatible return type
`
toString() in Sphere cannot override toString() in java.lang.Object; attempting to use incompatible return type
toString() in Cube cannot override toString() in java.lang.Object; attempting to use incompatible return type
thanks
You need to change the return type of the function to
Stringand return the text instead of writing it toSystem.out.EDIT: If you want to have a method that outputs the object directly to
System.outin textual form, you’ll need to call it something else thantoString(). This is becausetoString()is a method belonging tojava.lang.Objectwhich all Java classes automatically extend.