Question: Using the Singleton pattern examples found in this chapter, create a program to accomplish the following: 1. Implement either an interface for a President to
Using the Singleton pattern examples found in this chapter, create a program to accomplish the following:
1. Implement either an interface for a President to Resign() or implement the interface to Impeach() a President. Your method should delete the current Singleton President (and remove that link from the SingletonDestroyer). SingletonDestroyer has a setSingleton() method that may be useful to aid in removing the backlink.
2. Noting that the former Singleton President has been removed, create a new President using President::instance(). Verify that the new President has been installed.
3. (Optional) Create a Registry to allow Singleton to be used effectively in multiple classes (not mutually exclusively, as is the current implementation).
Step by Step Solution
3.34 Rating (154 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
