- 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.
推薦閱讀
- 多媒體CAI課件設計與制作導論(第二版)
- Testing with JUnit
- Interactive Data Visualization with Python
- SAS數據統計分析與編程實踐
- Unity 5.x By Example
- C語言程序設計學習指導與習題解答
- 從Excel到Python:用Python輕松處理Excel數據(第2版)
- Hands-On Automation Testing with Java for Beginners
- Java Web開發詳解
- Learning PHP 7
- 編寫高質量代碼:改善Objective-C程序的61個建議
- MATLAB GUI純代碼編寫從入門到實戰
- Julia數據科學應用
- Drupal 8 Development Cookbook(Second Edition)
- Parallel Programming with Python