forked from hazukac/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPage.java
More file actions
33 lines (31 loc) · 943 Bytes
/
Page.java
File metadata and controls
33 lines (31 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package factory;
// TODO: たぶん、java.io.FileWriterだけでいい気がする
import java.io.Writer;
import java.io.FileWriter;
import java.io.IOException;
// TODO: たぶんVectorだけ
import java.util.*;
public abstract class Page {
protected String title;
protected String author;
protected Vector<Item> content = new Vector<Item>();
public Page(String title, String author) {
this.title = title;
this.author = author;
}
public void add(Item item) {
content.add(item);
}
public void output() {
try {
String filename = title + ".html";
Writer writer = new FileWriter(filename);
writer.write(this.makeHTML());
writer.close();
System.out.println(filename + "を作成したました");
} catch (IOException e) {
e.printStackTrace();
}
}
public abstract String makeHTML();
}