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 1. Well-Designed Apps Rock: Great Software Begins Here、CODE MAGNETS(No. 636)を解いてみる。
その他参考書籍
CODE MAGNETS(No. 636)
コード(BBEdit, Emacs)
Inventory.java
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
public class Inventory {
private List guitars;
// ...
public List search(Guitar searchGuitar) {
List matchingGuitars = new LinkedList();
for (Iterator i = guitars.iterator(); i.hasNext();) {
Guitar guitar = (Guitar)i.next();
if (searchGuitar.getBuilder() != guitar.getBuilder())
continue;
String model = searchGuitar.getModel();
if ((model != null) && (!model.equals("")) &&
(!model.equals(guitar.getModel())))
continue;
if (searchGuitar.getType() != guitar.getType())
continue;
if (searchGuitar.getBackWood() != guitar.getBackWood())
continue;
if (searchGuitar.getTopWood() != guitar.getTopWood())
continue;
matchingGuitars.add(guitar);
}
return matchingGuitars;
}
}
入出力結果(Terminal)
$ javac Inventory.java Note: Inventory.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. $
0 コメント:
コメントを投稿