Head First Object-Oriented Analysis and Design
A Brain Friendly Guide to OOA&D
(O'Reilly Media)
Brett McLaughlin (著),Gary Pollice (著)
David West (著)
邦訳
Head Firstオブジェクト指向分析設計
頭とからだで覚えるオブジェクト指向の基本
長瀬 嘉秀 (編集), 永田 渉 (編集)
株式会社テクノロジックアート (翻訳)
開発環境
- OS X Yosemite - Apple (OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Java (プログラミング言語)
- javac (コンパイラ)
- java (application launcher)
Head First Object-Oriented Analysis and Design: A Brain Friendly Guide to OOA&D (Brett McLaughlin (著)、Gary Pollice (著)、David West (著)、 O'Reilly Media)のChapter 2. Gathering Requirements: Give Them What They Want、CODE MAGNETS(No. 1142)を解いてみる。
その他参考書籍
CODE MAGNETS(No. 1142)
コード(BBEdit, Emacs)
Remote.java
public class Remote {
private DogDoor door;
public Remote(DogDoor door) {
this.door = door;
}
public void pressButton() {
System.out.println("Pressing the remote control button...");
if (door.isOpen()) {
door.close();
} else {
door.open();
}
}
}
RemoteTester.java
public class RemoteTester {
public static void main(String[] args)
{
DogDoor door = new DogDoor();
Remote remote = new Remote(door);
remote.pressButton();
remote.pressButton();
remote.pressButton();
remote.pressButton();
remote.pressButton();
}
}
入出力結果(Terminal)
$ jrun.sh RemoteTester Pressing the remote control button... The dog door opens. Pressing the remote control button... The dog door closes. Pressing the remote control button... The dog door opens. Pressing the remote control button... The dog door closes. Pressing the remote control button... The dog door opens. $
0 コメント:
コメントを投稿