- 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.
推薦閱讀
- Oracle從入門到精通(第3版)
- 零基礎學C++程序設計
- PostgreSQL for Data Architects
- Java加密與解密的藝術
- INSTANT Sinatra Starter
- HTML 5與CSS 3權威指南(第3版·上冊)
- 打開Go語言之門:入門、實戰與進階
- R數據科學實戰:工具詳解與案例分析
- Fast Data Processing with Spark(Second Edition)
- C語言程序設計實訓教程與水平考試指導
- Exploring SE for Android
- Application Development with Parse using iOS SDK
- C語言從入門到精通
- 微信小程序開發圖解案例教程:附精講視頻(第3版)
- 深度剖析ApacheDubbo核心技術內幕