2014年12月20日土曜日

開発環境

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. 1518)を解いてみる。

その他参考書籍

CODE MAGNETS(No. 1518)

コード(BBEdit, Emacs)

DogDoorSimulator.java

public class DogDoorSimulator {
    public static void main(String[] args)
    {
        DogDoor door = new DogDoor();
        Remote remote = new Remote(door);

        System.out.println("Fido barks to go outside...");
        remote.pressButton();
        System.out.println("\nFido has gone outside...");
        System.out.println("\nFido's all done...");

        try {
            Thread.currentThread().sleep(10000);
        } catch (InterruptedException e) {}

        System.out.println("...but he's stuck outside.");
        System.out.println("\nFido starts barking...");
        System.out.println("...so Todd grabs the remote control.");
        remote.pressButton();
        System.out.println("\nFido's back inside...");
    }
}

入出力結果(Terminal)

$ jrun.sh DogDoorSimulator
Fido barks to go outside...
Pressing the remote control button...
The dog door opens.

Fido has gone outside...

Fido's all done...
The dog door closes.
...but he's stuck outside.

Fido starts barking...
...so Todd grabs the remote control.
Pressing the remote control button...
The dog door opens.

Fido's back inside...
The dog door closes.
$

0 コメント:

コメントを投稿