- 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.
推薦閱讀
- PHP動(dòng)態(tài)網(wǎng)站程序設(shè)計(jì)
- Vue.js設(shè)計(jì)與實(shí)現(xiàn)
- Visual Basic 6.0程序設(shè)計(jì)計(jì)算機(jī)組裝與維修
- MySQL數(shù)據(jù)庫(kù)管理與開(kāi)發(fā)(慕課版)
- Java性能權(quán)威指南(第2版)
- Apache Mesos Essentials
- KnockoutJS Starter
- Salesforce Reporting and Dashboards
- Python算法詳解
- Java程序設(shè)計(jì)教程
- Python程序設(shè)計(jì)教程
- JavaScript前端開(kāi)發(fā)基礎(chǔ)教程
- Mastering Node.js
- 軟件測(cè)試項(xiàng)目實(shí)戰(zhàn)之功能測(cè)試篇
- 算法(第4版)