Isn't this way simpler? (two methods to check if ball 19 and 20 are strikes)

Can someone tell me if the code I wrote is any good? I think it keeps the logic pretty clear and simple, using pretty much the original code and a couple more methods to check if bowl 19 and 20 are strikes. I run many tests and everything seems to work fine. Don’t know if there is any case where this will fail, but I couldn’t find it.

public Action Bowl(int pins) {

    if (bowl >= 19 && Bowl21Awarded()) {
        if (bowl == 20 && Bowl19IsStrike() && Bowl20NotAStrike()) {
            bowl += 1;
            return Action.TIDY;
        } else {
            bowl += 1;
            return Action.RESET;
        }
}

the logic of the methos I used is pretty obvious:

private bool Bowl19IsStrike() {
    return (bowls[19 - 1] == 10);
}

private bool Bowl20NotAStrike() {
    return (bowls[20 - 1] != 10);
}

Any comments or help is much appreciated! Thank you

Obviously I used the methods just for clarity’s sake, you could refactor everything avoiding using them and only use the equations in the “if”. In the next lessons, using this code I didn’t have any of the errors from the tests, like the one testing reset and endTurn on a turkey in the last frame.

I think your code is very well done; much more cleaner and easier for me to maintain than the one in the lecture. Thanks for sharing and great job!

One note: when I tried your code as written, I got an error for the “Game ends at bowl 20” test, i.e. if the I bowl 1 and 1 for the first two bowls of the 10th frame, I was expecting endGame but I got an endTurn.
I added this code to the if statement:

    if (bowl >= 19 && Bowl21Awarded ()) {
		if (bowl == 20 && Bowl19IsStrike () && Bowl20NotStrike ()) {
			bowl++;
			return Action.Tidy;
		} else {
			bowl++;
			return Action.Reset;
		}
	} else if (bowl == 20) {
		return Action.EndGame;
	}

Other than that, I really liked your approach. Thanks for sharing!