Created
December 25, 2016 05:47
-
-
Save kodaitakahashi/b6070ddf5ec29ef83c4d5d7caaf6919b to your computer and use it in GitHub Desktop.
Adapter
HTMLジェネレーター(
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
package adapter; | |
public class HTML { | |
private String string; | |
public HTML(String string) { | |
this.string = string; | |
} | |
/** | |
* brタグの中にstringを表示する | |
*/ | |
public void showWithBreak() { | |
System.out.println("<br>" + string + "</br>"); | |
} | |
/** | |
* smallタグの中にstringを表示する | |
*/ | |
public void showWithSmall() { | |
System.out.println("<small>" + string + "</small>"); | |
} | |
/** | |
* stringタグの中にstringを表示する | |
*/ | |
public void showWithStrong() { | |
System.out.println("<strong>" + string + "</string>"); | |
} | |
} |
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
package adapter; | |
public class Main { | |
public static void main(String[] args) { | |
Tag html = new PrintHTML("Hello World"); | |
html.printBreak(); | |
html.printSmall(); | |
html.printStrong(); | |
} | |
} |
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
package adapter; | |
public class PrintHTML extends HTML implements Tag{ | |
public PrintHTML(String string){ | |
super(string); | |
} | |
public void printBreak() { | |
showWithBreak(); | |
} | |
public void printSmall() { | |
showWithSmall(); | |
} | |
public void printStrong() { | |
showWithStrong(); | |
} | |
} |
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
package adapter; | |
public interface Tag { | |
public abstract void printBreak(); | |
public abstract void printSmall(); | |
public abstract void prin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment