...
Start by examining the existing
ReportHeader
Singleton class to understand how it is implemented.Create a new Singleton class called
ReportFooter
. This class should be structured similarly to theReportHeader
class.It should have a private constructor.
It should have a private static volatile instance of
ReportFooter
.It should have a public static method,
getInstance()
, that returns the instance ofReportFooter
, instantiating it if it is null.It should contain a private String
footer
that is initialized in the constructor with the contents of the footer (for example, "Company Name\nAddress\nEnd of Report\n\n").It should have a
printFooter()
method that printsfooter
to the console.
Update the
ReportWriter
driver class to demonstrate the use of the newReportFooter
class. After printing the header, it should retrieve the footer usingReportFooter.getInstance()
and print it using theprintFooter()
method.Test your application to ensure that it behaves as expected.
...
You should submit your completed Java files for ReportHeader
, ReportFooter
, and ReportWriter
.Driver
...
Remember, the goal of this lab is to understand the Singleton pattern and how it can be used to manage global application state. Good luck!