
you are here
479
11
章
Proxy
パターン
public class MatchMakingTestDrive {
//
ここにインスタンス変数が入る
public static void main(String[] args) {
MatchMakingTestDrive test = new MatchMakingTestDrive();
test.drive();
}
public MatchMakingTestDrive() {
initializeDatabase();
}
public void drive() {
Person joe = getPersonFromDatabase("
ジョー・ジャバビーン
");
Person ownerProxy = getOwnerProxy(joe);
System.out.println("
名前は
" + ownerProxy.getName());
ownerProxy.setInterests("
ボーリング、囲碁
");
System.out.println("
所有者プロキシから趣味を設定
");
try {
ownerProxy.setGeekRating(10);
} catch (Exception e) {
System.out.println("
所有者プロキシからはギーク度を設定できません
");
}
System.out.println("
ギーク度は
" + ownerProxy.getGeekRating()); ...