- Test-Driven Java Development(Second Edition)
- Alex Garcia Viktor Farcic
- 94字
- 2021-06-24 18:31:53
Implementation
The implementation of this specification is almost the same as the previous one. All we have to do is throw an exception if y does not fall within the defined range:
public void play(int x, int y) { if (x < 1 || x > 3) { throw new RuntimeException("X is outside board"); } else if (y < 1 || y > 3) { throw new RuntimeException("Y is outside board"); } }
In order for the last test to pass, we had to add the else clause that checks whether Y is inside the board.
Let's do the last test for this requirement.
推薦閱讀
- Debian 7:System Administration Best Practices
- Arduino by Example
- React Native Cookbook
- Android Application Development Cookbook(Second Edition)
- Learning Informatica PowerCenter 10.x(Second Edition)
- 基于差分進化的優化方法及應用
- 游戲程序設計教程
- 軟件項目管理實用教程
- Spring MVC+MyBatis開發從入門到項目實踐(超值版)
- Python硬件編程實戰
- 深入理解Java虛擬機:JVM高級特性與最佳實踐
- Java 7 Concurrency Cookbook
- 每個人的Python:數學、算法和游戲編程訓練營
- 少年小魚的魔法之旅:神奇的Python
- JavaScript全棧開發