4. quot; Have you ever had a dream,
Neo, that you were so sure was
real?
What if you were unable to wake
from that dream, Neo?
How would you know the
difference between the dream
world and the real. quot;
Morpheus
52. スタック step5 impl.
private List stack_; // step 5
public Stack() {
stack_ = new ArrayList(); // step 5
}
public boolean isEmpty() {
if ( stack_.size() > 0) { // step 5
return false;
}
return true;
}
public void push(Object o) {
…
stack_.add(o); // step 5
}
53. スタック step6
• test
public void testOneInAndOutEmpty() {
stack.push(new String(quot;firstquot;));
stack.pop(); // step 6
}
• implementation
public Object pop() {
return new Object(); // step 6
}
54. スタック step7
• test
public void testOneInAndOutEmpty() {
…
assertTrue(stack.isEmpty()); // step 7
}
• implementation
public Object pop() {
return stack_.remove(size()-1); // step 7
}
55. スタック step8
• test
public void testLastInFirstOut() {
stack.push(new String(quot;firstquot;));
stack.push(new String(quot;secondquot;));
stack.push(new String(quot;thirdquot;));
assertEquals(quot;thirdquot;, stack.pop()); // step 8
}
• Implementation
– Remains as it is.
56. スタック step9
• test
public void testLastInFirstOut() {
…
assertEquals(quot;secondquot;, stack.pop());
assertEquals(quot;firstquot;, stack.pop()); // step 9
}
• Implementation
– Remains as it is.
88. Bibliography
• Rebirth
– Kent Beck
– http://www.tech-arts.co.jp/xp/Rebirth.pdf
• Test-Driven Development
– Kent Beck
– TDD Training text [2002/09/11-12]
– http://www.tech-arts.co.jp/training/topics.html
– 但し、テキストは公開されていないようです。