07/02/06 11:34:02
if( ( game[0] == 7 ) ||
( game[0] == 6 && game[1] < 5 ) ) {
return "Player1 wins the set " + games[0] + " - " games[1];
}
if( ( game[1] == 7 ) ||
( game[1] == 6 && game[0] < 5 ) ) {
return "Player2 wins the set " + games[1] + " - " games[0];
}
if( games[0] > games[1] ) {
return "Player1 leads " + games[0] + " - " + games[1];
}
if( games[0] < games[1] ) {
return "Player2 leads " + games[1] + " - " + games[0];
}
return "Set is tied at " + games[0] + "games";
上の方式でif列挙にするとしたらこうだよな。
あとは数値の定数化。
ついでにgamesWon関数で数値の範囲例外処理行わないとNG。
引数のPlayerが4とか来た場合とか、
呼ばれすぎて勝利数が両方8とかになったらどうするつもりかと小一時間(ry