Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adapter HTMLジェネレーター(
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>");
}
}
package adapter;
public class Main {
public static void main(String[] args) {
Tag html = new PrintHTML("Hello World");
html.printBreak();
html.printSmall();
html.printStrong();
}
}
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();
}
}
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
You can’t perform that action at this time.