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
The best way to learn is to practice. Below, you will find some of the solutions other golfers have entered. To unlock higher ranked solutions, submit your own entry which does as well or better than the solutions you can currently see - climb the ladder!
Check out these helpful resources to improve your Vim skills... Game on.
Unlock 25 remaining solutions by signing in and submitting your own entry
#26 Erik Buček / @_EnterNameHere_ - Score: 51 - 11/19/14 @ 09:54
9jqq3wywjddOlog(LogLevel.<Esc>"0pbveUA, str);<Esc>4j0q6@qZZ
0 comments
#27 Oliver Christ / @0liverChrist - Score: 51 - 02/13/15 @ 21:37
10Gqqww"ayt(+Clog(LogLevel.<C-R>a, str);<Esc>T.vt,~4+q6@qZZ
0 comments