Software Design 2010年7月号《補足》#2: 図解(総天然色版)
|小粒ちゃんねる|
小粒ちゃんねる #小粒ch
《著》小粒ちゃん@湘南組、小粒ちゃん@博多組
|関連記事|
Software Design 連載記事
ここでは、掲載記事に関する補足情報を公開しています。
老頭児(ロートル)エンジニアのつぶやき
ケース1:16進数の文字列表記
- リスト6 switch文の隘路(その1)
public int hexValue(char ch) throws NonHexDigitException { switch (ch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': return (ch - '0'); case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': return (ch - 'a') + 10; case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': return (ch - 'A') + 10; default: throw new NonHexDigitException(ch); } }
ケース2:カードゲーム
- リスト7 switch文の隘路(その2)
public String toString() { StringBuffer buf = new StringBuffer(); buf.append(suit); switch (number) { case 1: buf.append("A") ; break; case 10: buf.append("O") ; break; case 11: buf.append("J") ; break; case 12: buf.append("Q") ; break; case 13: buf.append("K") ; break; default: buf.append(number); break; } return buf.toString(); }
↑TOP
関連記事
- @
Last updated♪2010/06/22
*1:p1.hand == R and p2.hand == R) or (p1.hand == P and p2.hand == P) or (p1.hand == S and p2.hand == S