-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 challenge #1606
base: main
Are you sure you want to change the base?
Bowling challenge #1606
Conversation
roll(points) { | ||
// check if frame has already ended | ||
if (this.rolls.length == 2 || this.rolls.includes(10)) { | ||
throw new Error('Tried to add points to a frame that is already over'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this part where you are catching the error.
points_array.forEach((points) => { | ||
this.roll(points); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe to change this for the interface?
game.js
Outdated
for(let i = 0; i < 10; i++) { | ||
let frame = new frameClass(); | ||
this.frames.push(frame); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a method, maybe?
game.js
Outdated
if (this.frames[9].isStrike() && this.frames[8].isStrike()) { | ||
this.frames[8].bonusPoints += bonusRollsArray[0]; | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Tom, I think your code is good, especially your tests. I believe you predicted a lot of things that could go wrong in the program in your tests, so you already threw exceptions for those cases.
I like that you've already created your frames at the beginning with 10, so you're sure you won't have a null number. That was pretty smart!
... supplied as default paramter to Game constructor.
No description provided.