Exercise 7: More Features of Classes

This exercise builds on the previous one, exploring additional features: method overloading, method overriding and the use of exceptions to signal errors. To get started, copy your both files of your Exercise 6 solution to a new directory, then modify the Circle class in the following ways:

This is what the new version of the class looks like in UML form:

UML representation of Circle class

Next…

Modify the program in the CircleDemo class so that it helps you to see whether the overloaded default constructor and the overridden toString() and equals() methods are working properly.

Then modify the program so that it attempts to create an invalid Circle object. Run the program to observe its behaviour, then modify it so that it catches the exception that is generated.

Tips