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 Exercise 6 solution (both files) to the directory exercises/ex7 in your cloned repository.

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.

When you are confident that the new version of the class is working as required, go to Submit My WorkExercises 6-10Exercise 7 in Minerva to submit your Circle.java file (and only that file) for grading. You can improve your solution and resubmit as many times as you like until the deadline. Also, don’t forget to commit all your work (i.e., both files) to your Git repository and push those commits up to GitLab.

Tips