To get experience using the Singleton pattern.
For this exercise, you will turn a regular class into a singleton class that only allows one instance to be created.
The Logger class provides a way to log messages in three different categories, errors, warnings, and info messages. It allows for directing these three different types of messages to different places. This way, we could choose which go to the screen, a file, or are ignored completely.
This class might be a good candidate to be a singleton. Rather than worry about creating multiple Logger objects, or pass them around to different methods, we could make it a single object.
The LoggerExample.java program provides a main method that tests out this class. You should change these two files so that the Logger class is a singleton.
When you are done, please submit the Java code under the assignment in Canvas.
Copyright © 2024 Ian Finlayson | Licensed under a Creative Commons BY-NC-SA 4.0 License.