Programming Exercises

4.1 Imagine you are creating an application that has a number of different tools a user may invoke. These tools need a special context to work in. The context describes the current active selection in the application. The selection consists of a reference to an arbitrary object. We wish to create a class representing an editing context that the tools may use. This class should contain the aforementioned selection reference. We do not want to allow direct manipulation of the reference, but want to have methods in the context class that allow anyone to get and set the current selection.

Write such a class. Be sure to get the ...

Get Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.