Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bowling scorecard challenge #390

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

umutbaykan
Copy link

validating whether a user is allowed to get additional shots (after strike/sparing the 10th one) is assumed to be handled by the UI so havent been incorporated

Copy link

@SomthingInteresting SomthingInteresting left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code has a bunch of tests that cover both state and behavior, making it pretty solid. It's easy to read and organised, plus it's got some nice error handling with clear explanations.

On the flip side, it could do a better job sticking to the Single Responsibility Principle since some methods are juggling a few tasks at once. Splitting them up would make the code even better.

Overall, it's a good piece of code, but with a few tweaks, it could be even better!

return message
end

def add_bonus_frame(*args)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the focus points provided to us I would suggest encapsulating the Frame logic into a seperate class. This would make it more modular and the bowlingscorer class would be only responsible for managing the Frames rather than the logic.


## Helper methods - Used in testing and not relevant to gameplay ##
def frames
@frames

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume if you had multiple classes you would've used accessor methods to access these instance variables instead?

it "fails if user inputs negative numbers" do
expect{bowl.add_frame(4,-5)}.to raise_error "Smells like invalid input"
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fail scenarios but would suggest one for non numeric input, floating point and maybe other types but that's just me nitpicking.

@player_score += @frames[-1].flatten.sum
end

def count_frame_score(index)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to split the responsibilities out here as it currently calculates the frame score and the special cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants