forked from hazukac/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMain.java
More file actions
46 lines (45 loc) · 1.13 KB
/
Main.java
File metadata and controls
46 lines (45 loc) · 1.13 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
public class Main {
public static void main(String[] args) {
AbstractDisplay d0 = new CharDisplay('B');
AbstractDisplay d1 = new CharDisplay("A");
AbstractDisplay d2 = new StringDisplay("Hello, World!!");
AbstractDisplay d3 = new StringDisplay("Hoge Fuga Piyo");
d0.display();
d1.display();
d2.display();
d3.display();
}
}
/*
open - process - close
*/
/*
イベントサイトのレスポンスが違う
class Crawler {
abstract url: sring;
crawl() {
c := this.getContent();
r := this.parse(c);
s := this.close();
}
getContet() {
return http.Get(this.url);
}
}
class AsahiBeerCrawler extends Crawler {
constructor() {
this.url = "http://asahi.com/campaign";
}
parse(c http.Response) {
// アサヒビールのページのHTMLをパースする具体的な処理
}
close() {
// アサヒビールのページのリクエストをクロースずる処理
}
}
class KirinBeerCrawler extends Crawler {
constructor() {
this.url = "http://kirin.com/?view=campaign";
}
}
*/