Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string FormatRolls(List<int> rolls){
- string output = "";
- for (int i = 0, box = 1; i < rolls.Count; i++) {
- if (box >= 19 && rolls [i] == 10) { //Strike in last frame
- output += "X";
- box++;
- } else if ((box > 1 && rolls [i] == 10 && rolls [i - 1] != 0) || //Strike in frames 1-9
- (box == 1 && rolls [i] == 10)) {
- output += "X "; //Increment 2 since second
- box += 2; //bowl in frame isn't needed
- } else if (rolls [i] == 0) { //Gutterball
- output += "-";
- box++;
- } else if (((box % 2) == 0 || box == 21) && rolls [i - 1] + rolls [i] == 10) { //Spare
- output += "/";
- box++;
- } else {
- output += rolls [i].ToString (); //1 to 9 pin falls
- box++;
- }
- }
- return output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement