Code Monkey home page Code Monkey logo

bowling-challenge's Introduction

Bowling Challenge

  • Feel free to use google, your notes, books, etc. but work on your own
  • If you refer to the solution of another coach or student, please put a link to that in your README
  • If you have a partial solution, still check in a partial solution
  • You must submit a pull request to this repo with your code by 9am Monday week

The Task

THIS IS NOT A BOWLING GAME, IT IS A BOWLING SCORECARD. DO NOT GENERATE RANDOM ROLLS. AN ACTUAL USER INTERFACE IS OPTIONAL

Count and sum the scores of a bowling game for one player (in JavaScript).

A bowling game consists of 10 frames in which the player tries to knock down the 10 pins. In every frame the player can roll one or two times. The actual number depends on strikes and spares. The score of a frame is the number of knocked down pins plus bonuses for strikes and spares. After every frame the 10 pins are reset.

Start by looking in detail at the rules and the example of scoring for a complete game given below.

An example of how your code might be used could be:

let scorecard = new Scorecard()
scorecard.calculateScore() // returns 0
scorecard.addFrame(2, 5) 
scorecard.addFrame(3, 5)
scorecard.calculateScore() // returns 15

But feel free to add other methods if you think they are useful.

As usual please start by

  • Forking this repo

  • Using test-driven development (if you decide to write a user interface, then make sure you have looked at the chapters on mocking).

  • Finally submit a pull request before Monday week at 9am with your solution or partial solution. However much or little amount of code you wrote please please please submit a pull request before Monday week at 9am.

STRONG HINT, IGNORE AT YOUR PERIL: Bowling is a deceptively complex game. Careful thought and thorough diagramming — both before and throughout — will save you literal hours of your life.

Optional Extras

In any order you like:

  • Set up Travis CI to run your tests.
  • Add ESLint to your codebase and make your code conform.
  • Create a UserInterface class, allowing you to run a game from the command line.

You might even want to start with ESLint early on in your work — to help you learn Javascript conventions as you go along.

Bowling — how does it work?

Strikes

The player has a strike if he knocks down all 10 pins with the first roll in a frame. The frame ends immediately (since there are no pins left for a second roll). The bonus for that frame is the number of pins knocked down by the next two rolls. That would be the next frame, unless the player rolls another strike.

Spares

The player has a spare if the knocks down all 10 pins with the two rolls of a frame. The bonus for that frame is the number of pins knocked down by the next roll (first roll of next frame).

10th frame

If the player rolls a strike or spare in the 10th frame they can roll the additional balls for the bonus. But they can never roll more than 3 balls in the 10th frame. The additional rolls only count for the bonus not for the regular frame count.

10, 10, 10 in the 10th frame gives 30 points (10 points for the regular first strike and 20 points for the bonus).
1, 9, 10 in the 10th frame gives 20 points (10 points for the regular spare and 10 points for the bonus).

Gutter Game

A Gutter Game is when the player never hits a pin (20 zero scores).

Perfect Game

A Perfect Game is when the player rolls 12 strikes (10 regular strikes and 2 strikes for the bonus in the 10th frame). The Perfect Game scores 300 points.

In the image below you can find some score examples.

More about ten pin bowling here: http://en.wikipedia.org/wiki/Ten-pin_bowling

Ten Pin Score Example

Code Review

In code review we'll be hoping to see:

  • All tests passing
  • The code is elegant: every class has a clear responsibility, methods are short etc.

Reviewers will potentially be using this code review rubric. Note that referring to this rubric in advance may make the challenge somewhat easier. You should be the judge of how much challenge you want.

bowling-challenge's People

Contributors

anitacanita avatar edwardandress avatar gypsydave5 avatar johnforster avatar maryrosecook avatar neoeno avatar ptolemybarnes avatar roidriscoll avatar samir70 avatar spike01 avatar tansaku avatar tatsiana-makers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bowling-challenge's Issues

Clarify the requirement to build a score "calculator"

Having discussed this with several others in my cohort, many of us were under the impression that we should build a bowling game, where the user would click a roll button and this would generate a random roll outcome.

I suggest clarifying the requirements to build a score calculator that takes user input for rolls and is used as a visual guide. A link to an example, such as Bowling Genius, might also help.

Minor point on problem description - main vs bonus features

The retro for this weekend challenge focused primarily on how to write the UI for the bowling challenge, particularly writing the UI in jQuery, program flow between the UI and model layer, writing jQuery UI code in render methods like you would write React UI code, etc.

Reading the problem description (and the review.md document) it isn't clear that the UI is such an essential feature of this weekend challenge, as it is listed in the 'optional' or 'bonus' extras section. It is clear to me now that working on the UI would have been a more valuable thing to start with this weekend. Our coach (Mark) also suggested that he started with the UI first.

I'd suggest that none of the learning of the weekend challenge would suffer if the UI was listed among the main features rather than as an optional feature, as this seems to be how most people in the retro and our coach thought about it anyway.

Thanks!

Improve instructions

One student wanted to mock user input for his tests, because the instructions specifically say that the user will input data. To fix that:

  • clarify the instructions as being unit tests, so whole input process doesn't need to part of that.
  • Give a class outline with, say, two methods: inputFrame() and getFinalScore()
  • Some examples of expectations that the students could turn into jest tests. (There is an example at the bottom that could be turned into a test)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.