- Test-Driven Java Development(Second Edition)
- Alex Garcia Viktor Farcic
- 93字
- 2021-06-24 18:31:54
Implementation
In order to track who should play next, we need to store who played last:
private char lastPlayer = '\0'; public void play(int x, int y) { checkAxis(x); checkAxis(y); setBox(x, y); lastPlayer = nextPlayer(); } public char nextPlayer() { if (lastPlayer == 'X') { return 'O'; } return 'X'; }
You are probably starting to get the hang of it. Tests are small and easy to write. With enough experience, it should take a minute, if not seconds, to write a test and as much time or less to write the implementation.
推薦閱讀
- PaaS程序設(shè)計
- Django開發(fā)從入門到實踐
- 編寫高質(zhì)量代碼:改善C程序代碼的125個建議
- Processing互動編程藝術(shù)
- JS全書:JavaScript Web前端開發(fā)指南
- MATLAB定量決策五大類問題
- HTML5從入門到精通(第4版)
- Solr Cookbook(Third Edition)
- Learning Material Design
- Python函數(shù)式編程(第2版)
- The Statistics and Calculus with Python Workshop
- Node.js實戰(zhàn):分布式系統(tǒng)中的后端服務(wù)開發(fā)
- Flink核心技術(shù):源碼剖析與特性開發(fā)
- LabVIEW入門與實戰(zhàn)開發(fā)100例(第4版)
- React.js實戰(zhàn)