Created
May 3, 2014 13:06
-
-
Save Khanashima/11497565 to your computer and use it in GitHub Desktop.
オブジェクト指向に近づく9つのルール (ThoughtWorks アンソロジーより) ref: http://qiita.com/kiimiiis/items/dab7ebbcab640b4f2aa0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Board { | |
String board() { | |
StringBuffer buf = new StringBuffer(); | |
for (int i = 0; i < 10; i++) { | |
for (int j = 0; j < 10; j++) { | |
buf.append(data[i][j]); | |
} | |
buf.append("\n"); | |
} | |
return buf.toString(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Board { | |
//1つのメソッドにつきインデントは1段階までにする | |
String board() { | |
StringBuffer buf = new StringBuffer(); | |
collectRows(buf); | |
return buf.toString(); | |
} | |
void collectRows(StringBuffer buf) { | |
for (int i = 0; i < 10; i++) { | |
collectRow(buf, i) | |
} | |
} | |
void collectRow(StringBuffer buf, int row) { | |
for (int i = 0; i < 10; i++) { | |
buf.append(data[row][i]); | |
} | |
buf.append("\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment