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

[WIP] Implement exercise bowling #790

Merged
merged 30 commits into from
Jan 23, 2018
Merged

Conversation

thecouchcoder
Copy link
Contributor

@ilya-khadykin
Copy link
Contributor

@aes421 build failed due to some code style issues:

2.65s$ flake8
./exercises/bowling/bowling_test.py:73:1: E305 expected 2 blank lines after class or function definition, found 1
./exercises/bowling/example.py:13:9: E265 block comment should start with '# '
./exercises/bowling/example.py:25:17: E265 block comment should start with '# '

@ilya-khadykin
Copy link
Contributor

@aes421 you forgot to add the exercise to config.json:

-> An implementation for 'bowling' was found, but config.json does not reference this exercise.

@thecouchcoder
Copy link
Contributor Author

Hey @m-a-ge I'm actually not done writing the test/implementation of this exercise yet. I left the config stuff until last for me previous PR, but I can go ahead and do it now if you'd like.

@ilya-khadykin
Copy link
Contributor

Ah, sorry, my bad. Ping me when you're done.

Side note: I don't usually leave comments in WIP PRs, but some people forget to remove the tag and it's unclear whether PR is done or not

@thecouchcoder
Copy link
Contributor Author

@m-a-ge done with this one. Let me know what you'd like to see changed.

Copy link
Contributor

@ilya-khadykin ilya-khadykin left a comment

Choose a reason for hiding this comment

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

Good work overall!

I left comments for you to address.
And I suggest you spend some time on refactoring to make your code a bit better

@@ -0,0 +1 @@
.cache/
Copy link
Contributor

@ilya-khadykin ilya-khadykin Oct 14, 2017

Choose a reason for hiding this comment

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

I would advise not to include this in repo .gitignore. You can use your local one for this purpose


from example import BowlingGame


Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please also leave a comment stating what version of canonical-data.json the tests were adopted as discussed in #784 if aplicable?
The format is:

# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.0

def test_should_be_able_to_score_a_game_with_all_zeros(self):
rolls = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

self.game = BowlingGame()
Copy link
Contributor

Choose a reason for hiding this comment

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

I would also suggest introduce a setUp method and create an instance of BowlingGame only once

def setUp(self):
        self.game= BowlingGame()

self.bonusRollsSeen = 0

def roll(self, pins):
if (self.isBonusRoll()):
Copy link
Contributor

Choose a reason for hiding this comment

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

probably just:

if self.isBonusRoll():
    # do stuff

This increases readability

raise ValueError

# open a new frame if the last one has been closed
if (self.currentFrame.isOpen() is False):
Copy link
Contributor

Choose a reason for hiding this comment

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

if not self.currentFrame.isOpen():

self.rolls[1] = roll
self.open = False

def isOpen(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

this doesn't look right, method name doesn't correspond to its actual function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what you mean on this one. you call isOpen to find out if the frame is open (true) or not (false)



class Frame(object):

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be great to add docstring


def isBonusRoll(self):
# if we've already seen all
if (len(self.rolls) >= NUM_FRAMES):
Copy link
Contributor

Choose a reason for hiding this comment

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

refactor to oneliner



class BowlingGame(object):
def __init__(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

docstring here would be nice 📓


self.game = BowlingGame()

for roll in rolls:
Copy link
Contributor

@ilya-khadykin ilya-khadykin Oct 14, 2017

Choose a reason for hiding this comment

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

Probably something like:

[self.game.roll(roll) for roll in rolls]

And the code is duplicated in every test which is not a good thing, should be refactored

Copy link
Contributor

@cmccandless cmccandless left a comment

Choose a reason for hiding this comment

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

There should be a solution template bowling.py included as well. See solution template for complex-numbers as an example.

@@ -0,0 +1,261 @@
import unittest

from example import BowlingGame
Copy link
Contributor

Choose a reason for hiding this comment

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

should be from bowling import BowlingGame

@thecouchcoder
Copy link
Contributor Author

Thanks for the feedback! I just got back from a holiday, and I'm hoping to have time to work on finishing this one later this week.

@stale
Copy link

stale bot commented Nov 28, 2017

This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the abandoned label Nov 28, 2017
@stale stale bot removed the abandoned label Nov 29, 2017
@thecouchcoder
Copy link
Contributor Author

I think I've got everything fixed up. Let me know what you think. @m-a-ge @cmccandless

@@ -1,258 +1,189 @@
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.1
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency with the other exercises, could you please move this line like so:

from bowling import BowlingGame


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.1

class BowlingTests(unittest.TestCase):
...

Please note the number of blank lines before and after.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

@stale
Copy link

stale bot commented Dec 22, 2017

This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the abandoned label Dec 22, 2017
@stale stale bot removed the abandoned label Dec 26, 2017
@cmccandless cmccandless merged commit f6ae46b into exercism:master Jan 23, 2018
@cmccandless
Copy link
Contributor

@aes421 Merged; thanks for working on this!

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.

3 participants