I have a program in Java with several classes, these being:
i) Shape ii) Square iii) Rectangle iv) Circle v) Triangle vi) Drawing Canvas vii) Application
Square, Rectangle, Circle and Triangle all inherit from class Shape
Now, in the Drawing Canvas class, I have two methods, one for writing objects of type Shape to a file and one for reading objects from the file.
This is the code:
The method which saves to the file works perfectly. However, I am having a problem reading the objects from the file and appending them to the Shapes ArrayList.
As it is, the application is given me the error that java.lang.String cannot be cast to shapes_assignment.Shape.
How can I read the text stored in the text file and use it to recreate the objects once more? Thanks :)