Question: readme.txt Modify all necessary files in this directory so that the Logger class can only be instantiated once. That instance should be used across all
readme.txt
Modify all necessary files in this directory so that the Logger class can only be instantiated once. That instance should be used across all classes which access the Logger.
logger.pseudo
| public class Logger { | |
| private String log; | |
| // Constructor | |
| public Logger(){ | |
| } | |
| // Log something | |
| public info(String information){ | |
| this.log.append(information); | |
| } | |
| } |
someClass.pseudo
| public SomeClass{ | |
| public main(){ | |
| Logger l = new Logger(); | |
| l.info("hello world"); | |
| } | |
| } |
someOtherClass.pseudo
| public SomeOtherClass{ | |
| public main(){ | |
| Logger l = new Logger(); | |
| l.info("hello from some other class!"); | |
| } | |
| } |
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
