- Create a new Implementation of
Logger
that makes all message uppercase and replace the existing one. - Create a new Implementation of
Logger
that inherits from the uppercase version. Add new functionality - Create a new
LogHandler
that inherits fromLogHandler
. This should allow for theLogger
to be changed after the constructor is used - Create a new
LogHandler
that can accept multipleLoggers
and uses all of them to display messages
Created
November 2, 2022 17:38
-
-
Save sdoward/ccd615f0d465c4af9c39115651252502 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Logger { | |
void log(String message); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LogHandler { | |
private Logger logger; | |
public LogHandler(Logger logger) { | |
this.logger = logger; | |
} | |
void handleLog(String message) { | |
logger.log(message); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) { | |
Logger logger = new PlainLogger(); | |
LogHandler logHandler = new LogHandler(logger); | |
logHandler.handleLog("hello world"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment