Replace Parameter with Explicit Methods
Implementing the methods of a Java Interface
Start file
import ch.xyz.Logger; public class LoggerImpl implements Logger { private void log(LogLevel lvl, String str) { /* Code */ } @Override public void emerge(String str) { throw new UnsupportedOperationException("Not supported yet."); } @Override public void alert(String str) { throw new UnsupportedOperationException("Not supported yet."); } @Override public void critical(String str) { throw new UnsupportedOperationException("Not supported yet."); } @Override public void warning(String str) { throw new UnsupportedOperationException("Not supported yet."); } @Override public void notice(String str) { throw new UnsupportedOperationException("Not supported yet."); } @Override public void info(String str) { throw new UnsupportedOperationException("Not supported yet."); } @Override public void debug(String str) { throw new UnsupportedOperationException("Not supported yet."); } }
End file
import ch.xyz.Logger; public class LoggerImpl implements Logger { private void log(LogLevel lvl, String str) { /* Code */ } @Override public void emerge(String str) { log(LogLevel.EMERGE, str); } @Override public void alert(String str) { log(LogLevel.ALERT, str); } @Override public void critical(String str) { log(LogLevel.CRITICAL, str); } @Override public void warning(String str) { log(LogLevel.WARNING, str); } @Override public void notice(String str) { log(LogLevel.NOTICE, str); } @Override public void info(String str) { log(LogLevel.INFO, str); } @Override public void debug(String str) { log(LogLevel.DEBUG, str); } }
View Diff
11c11 < throw new UnsupportedOperationException("Not supported yet."); --- > log(LogLevel.EMERGE, str); 16c16 < throw new UnsupportedOperationException("Not supported yet."); --- > log(LogLevel.ALERT, str); 21c21 < throw new UnsupportedOperationException("Not supported yet."); --- > log(LogLevel.CRITICAL, str); 26c26 < throw new UnsupportedOperationException("Not supported yet."); --- > log(LogLevel.WARNING, str); 31c31 < throw new UnsupportedOperationException("Not supported yet."); --- > log(LogLevel.NOTICE, str); 36c36 < throw new UnsupportedOperationException("Not supported yet."); --- > log(LogLevel.INFO, str); 41c41 < throw new UnsupportedOperationException("Not supported yet."); --- > log(LogLevel.DEBUG, str);
Solutions by @ramtamtamtam:
Unlock 1 remaining solutions by signing in and submitting your own entry