diff --git a/.gitignore b/.gitignore index e9bd1b1a66..7dd34bbf43 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/**/.DS_Store \ No newline at end of file +/**/.DS_Store +node_modules diff --git a/.hound.yml b/.hound.yml deleted file mode 100644 index 3d3e8ffe77..0000000000 --- a/.hound.yml +++ /dev/null @@ -1,3 +0,0 @@ -javascript: - ignore_file: .jshintignore - config_file: .jshintrc \ No newline at end of file diff --git a/.jshintignore b/.jshintignore deleted file mode 100644 index e9a8daabb6..0000000000 --- a/.jshintignore +++ /dev/null @@ -1,6 +0,0 @@ -vendor/* -lib/* -spec/* -*.md -**/*.html -*.LICENSE \ No newline at end of file diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 51e29b0443..0000000000 --- a/.jshintrc +++ /dev/null @@ -1,93 +0,0 @@ -{ - // JSHint Default Configuration File (as on JSHint website) - // See http://jshint.com/docs/ for more details - - "maxerr" : 50, // {int} Maximum error before stopping - - // Enforcing - "bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.) - "camelcase" : false, // true: Identifiers must be in camelCase - "curly" : true, // true: Require {} for every new block or scope - "eqeqeq" : true, // true: Require triple equals (===) for comparison - "forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty() - "freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc. - "immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` - "indent" : 2, // {int} Number of spaces to use for indentation - "latedef" : false, // true: Require variables/functions to be defined before being used - "newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()` - "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee` - "noempty" : true, // true: Prohibit use of empty blocks - "nonbsp" : true, // true: Prohibit "non-breaking whitespace" characters. - "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment) - "plusplus" : false, // true: Prohibit use of `++` & `--` - "quotmark" : false, // Quotation mark consistency: - // false : do nothing (default) - // true : ensure whatever is used is consistent - // "single" : require single quotes - // "double" : require double quotes - "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks) - "unused" : false, // Unused variables: - // true : all variables, last function parameter - // "vars" : all variables only - // "strict" : all variables, all function parameters - "strict" : false, // true: Requires all functions run in ES5 Strict Mode - "maxparams" : 4, // {int} Max number of formal params allowed per function - "maxdepth" : 2, // {int} Max depth of nested blocks (within functions) - "maxstatements" : 10, // {int} Max number statements per function - "maxcomplexity" : 4, // {int} Max cyclomatic complexity per function - "maxlen" : 80, // {int} Max number of characters per line - "varstmt" : false, // true: Disallow any var statements. Only `let` and `const` are allowed. - - // Relaxing - "asi" : true, // true: Tolerate Automatic Semicolon Insertion (no semicolons) - "boss" : false, // true: Tolerate assignments where comparisons would be expected - "debug" : false, // true: Allow debugger statements e.g. browser breakpoints. - "eqnull" : false, // true: Tolerate use of `== null` - "es5" : false, // true: Allow ES5 syntax (ex: getters and setters) - "esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`) - "moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features) - // (ex: `for each`, multiple try/catch, function expression…) - "evil" : false, // true: Tolerate use of `eval` and `new Function()` - "expr" : false, // true: Tolerate `ExpressionStatement` as Programs - "funcscope" : false, // true: Tolerate defining variables inside control statements - "globalstrict" : false, // true: Allow global "use strict" (also enables 'strict') - "iterator" : false, // true: Tolerate using the `__iterator__` property - "lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block - "laxbreak" : false, // true: Tolerate possibly unsafe line breakings - "laxcomma" : false, // true: Tolerate comma-first style coding - "loopfunc" : false, // true: Tolerate functions being defined in loops - "multistr" : false, // true: Tolerate multi-line strings - "noyield" : false, // true: Tolerate generator functions with no yield statement in them. - "notypeof" : false, // true: Tolerate invalid typeof operator values - "proto" : false, // true: Tolerate using the `__proto__` property - "scripturl" : false, // true: Tolerate script-targeted URLs - "shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;` - "sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation - "supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;` - "validthis" : false, // true: Tolerate using this in a non-constructor function - - // Environments - "browser" : true, // Web Browser (window, document, etc) - "browserify" : false, // Browserify (node.js code in the browser) - "couch" : false, // CouchDB - "devel" : true, // Development/debugging (alert, confirm, etc) - "dojo" : false, // Dojo Toolkit - "jasmine" : false, // Jasmine - "jquery" : false, // jQuery - "mocha" : true, // Mocha - "mootools" : false, // MooTools - "node" : false, // Node.js - "nonstandard" : false, // Widely adopted globals (escape, unescape, etc) - "phantom" : false, // PhantomJS - "prototypejs" : false, // Prototype and Scriptaculous - "qunit" : false, // QUnit - "rhino" : false, // Rhino - "shelljs" : false, // ShellJS - "typed" : false, // Globals for typed array constructions - "worker" : false, // Web Workers - "wsh" : false, // Windows Scripting Host - "yui" : false, // Yahoo User Interface - - // Custom Globals - "globals" : {} // additional predefined global variables -} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8756d9ff8d..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: node_js -node_js: -- "0.12" -before_install: -- "npm install grunt-cli" -- "npm install grunt" -- "npm install grunt-contrib-jasmine" -- "echo \"module.exports=function(grunt){grunt.initConfig({jasmine:{src:'src/**/*.js',options:{specs:'spec/**/*.js',keepRunner:false,vendor:['http://code.jquery.com/jquery-2.1.3.min.js','http://raw.githubusercontent.com/velesin/jasmine-jquery/master/lib/jasmine-jquery.js']}}});grunt.loadNpmTasks('grunt-contrib-jasmine');grunt.registerTask('default',['jasmine']);};\" > Gruntfile.js" -script: -- "grunt" diff --git a/README.md b/README.md index 7e2ced9eb9..f46e269586 100644 --- a/README.md +++ b/README.md @@ -9,44 +9,53 @@ Bowling Challenge * 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 -Task: ------ +## The Task 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. -As usual please start by +As usual please start by * Forking this repo * 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. And since next week is lab week you have a full extra week to work on this. +___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 Extra +### Optional Extras -Create a nice interactive animated interface with jQuery. +In any order you like: -## Strikes +* Create a nice interactive animated interface with jQuery. +* Set up [Travis CI](https://travis-ci.org) to run your tests. +* Add [ESLint](http://eslint.org/) to your codebase and make your code conform. + +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 +### 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 +### 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 +### Gutter Game A Gutter Game is when the player never hits a pin (20 zero scores). -## Perfect Game +### 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. @@ -56,24 +65,11 @@ More about ten pin bowling here: http://en.wikipedia.org/wiki/Ten-pin_bowling ![Ten Pin Score Example](images/example_ten_pin_scoring.png) -Code Review ------------ +## 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. +* The code is elegant: every class has a clear responsibility, methods are short etc. Reviewers will potentially be using this [code review rubric](docs/review.md). 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. - -CI --- - -We are running JSHint on our CI server - save yourself having to wait for a build to happen by linting your code on your machine first. [Here are installations for most popular editors](http://jshint.com/install/). Grab the `.jshintrc` from this repo and have better JS! - -If you don't follow the usual Jasmine convention of having your tests in `spec` and your code in `src`, or you've built your code into a little app, CI will probably fail for you as we are doing *sneaky things*™ to make your tests run. However, there is a simple fix: - -1. Open up your `.travis.yml` -2. On line 8, you will see where it looks for your code (`'src/**/*.js'`) and your tests (`'spec/**/*.js'`) -3. Adjust these to point to the correct directories -4. Done. diff --git a/REVIEW_GUIDELINES.md b/REVIEW_GUIDELINES.md deleted file mode 100644 index c5289920fb..0000000000 --- a/REVIEW_GUIDELINES.md +++ /dev/null @@ -1,32 +0,0 @@ -# Bowling Challenge: Review Guidelines - -## Style -- Lines no longer than 80 characters -- Short methods -- Descriptively named methods. Function names should ideally start with a verb so it's clear that they do something to something else. -- Methods have a single responsibility -- Appropriate semi-colon use -- No nested conditionals -- Code free of unnecessary comments and commented-out sections -- Consistent indentation - -## Testing -- Do the tests pass? -- Is master clean? (does the code work as is?) -- Tests organized under appropriate `describe` blocks. -- Are the tests descriptive? -- Are the tests DRY? (are they repeating themselves in the test in way that could be extracted) -- Is there any state being persisted between tests? -- Have they tested edge cases? Many solutions rely on a 'virtuous consumer' - i.e. they do not validate inputs or check for out of range values etc. - -## OOP -- Are your objects [solid](https://github.com/makersacademy/course/blob/master/pills/code_reviews.md#oop---are-your-objects-solid)? - - Have you separated responsibilities of... - - knowing whether a frame is a strike / spare - - keeping track of the progress of a game - - calculating bonuses -- Reliance on implementation details. It's common to see objects relying on the internals of other objects or their implementation of low-level types (particularly arrays). - -## Design -- Have they met the specification? Have they actually modelled the scoring of bowling? -- Is it overly complicated? (what's your gut feeling)