From e898737c565b95cebca9b287566fb4627327ab2e Mon Sep 17 00:00:00 2001 From: nae deshazer Date: Thu, 11 Jul 2019 20:55:21 -0500 Subject: [PATCH] done --- 04week/mastermind.js | 92 +++++++++++++++++++++----------------------- README.md | 56 +++++++++++++++++---------- 2 files changed, 79 insertions(+), 69 deletions(-) diff --git a/04week/mastermind.js b/04week/mastermind.js index 60e5cfa18..0ebf0447a 100644 --- a/04week/mastermind.js +++ b/04week/mastermind.js @@ -1,77 +1,73 @@ -'use strict'; +"use strict"; -const assert = require('assert'); -const readline = require('readline'); +const assert = require("assert"); +const readline = require("readline"); const rl = readline.createInterface({ - input: process.stdin, - output: process.stdout + input: process.stdin, + output: process.stdout }); let board = []; -let solution = ''; -let letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']; +let solution = ""; +let letters = ["a", "b", "c", "d", "e", "f", "g", "h"]; function printBoard() { - for (let i = 0; i < board.length; i++) { - console.log(board[i]); - } + for (let i = 0; i < board.length; i++) { + console.log(board[i]); + } } function generateSolution() { - for (let i = 0; i < 4; i++) { - const randomIndex = getRandomInt(0, letters.length); - solution += letters[randomIndex]; - } + for (let i = 0; i < 4; i++) { + const randomIndex = getRandomInt(0, letters.length); + solution += letters[randomIndex]; + } } function getRandomInt(min, max) { - return Math.floor(Math.random() * (max - min)) + min; + return Math.floor(Math.random() * (max - min)) + min; } function generateHint() { - // your code here + // your code here } function mastermind(guess) { - solution = 'abcd'; // Comment this out to generate a random solution - // your code here + // solution = 'abcd'; // Comment this out to generate a random solution + // your code here } - function getPrompt() { - rl.question('guess: ', (guess) => { - mastermind(guess); - printBoard(); - getPrompt(); - }); + rl.question("guess: ", guess => { + mastermind(guess); + printBoard(); + getPrompt(); + }); } // Tests -if (typeof describe === 'function') { - solution = 'abcd'; - describe('#mastermind()', () => { - it('should register a guess and generate hints', () => { - mastermind('aabb'); - assert.equal(board.length, 1); - }); - it('should be able to detect a win', () => { - assert.equal(mastermind(solution), 'You guessed it!'); - }); - }); - - describe('#generateHint()', () => { - it('should generate hints', () => { - assert.equal(generateHint('abdc'), '2-2'); - }); - it('should generate hints if solution has duplicates', () => { - assert.equal(generateHint('aabb'), '1-1'); - }); - - }); +if (typeof describe === "function") { + solution = "abcd"; + describe("#mastermind()", () => { + it("should register a guess and generate hints", () => { + mastermind("aabb"); + assert.equal(board.length, 1); + }); + it("should be able to detect a win", () => { + assert.equal(mastermind(solution), "You guessed it!"); + }); + }); + describe("#generateHint()", () => { + it("should generate hints", () => { + assert.equal(generateHint("abdc"), "2-2"); + }); + it("should generate hints if solution has duplicates", () => { + assert.equal(generateHint("aabb"), "1-1"); + }); + }); } else { - - generateSolution(); - getPrompt(); + generateSolution(); + getPrompt(); } diff --git a/README.md b/README.md index a4fd23648..46968c9ad 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,25 @@ [![CircleCI](https://circleci.com/gh/AustinCodingAcademy/javascript-workbook/tree/gh-pages.svg?style=svg)](https://circleci.com/gh/AustinCodingAcademy/javascript-workbook/tree/gh-pages) ![](http://en.gravatar.com/userimage/107370100/a08594145564536138dfaaf072c7b241.png) + # Austin Coding Academy ## JavaScript Workbook ### Claiming your workbook + 1. Click the 'Fork' button (choose your account if prompted). 1. Copy HTTPS URL from your forked repository 1. In your terminal (or in git bash, for Windows people), navigate (using `cd`) -into a directory where you want to start keeping your repositories. + into a directory where you want to start keeping your repositories. 1. Clone your new repository by typing `git clone ` (the HTTPS -URL you copied above) - ![Forking a repository](https://docs.google.com/drawings/d/1tYsLHaLo8JRdp0xC1EZrAo0o9Wvv4S5AD937cokVOBk/pub?w=960&h=720) + URL you copied above) + ![Forking a repository](https://docs.google.com/drawings/d/1tYsLHaLo8JRdp0xC1EZrAo0o9Wvv4S5AD937cokVOBk/pub?w=960&h=720) 1. Now go into the new directory by using `cd javascript-workbook` 1. Add the base repository as an upstream -`git remote add upstream https://github.com/AustinCodingAcademy/javascript-workbook.git` + `git remote add upstream https://github.com/AustinCodingAcademy/javascript-workbook.git` 1. Check the configuration of your remotes with `git remote -v`, it should look -very similar to this (except it'll be YOUR username) + very similar to this (except it'll be YOUR username) ```bash $ git remote -v @@ -29,44 +31,43 @@ upstream git@github.com:AustinCodingAcademy/javascript-workbook.git (push) ``` ### Push to Github and create a PR + 1. From your project directory, run `npm install` to tell NPM to install all the -node modules we use in this class + node modules we use in this class 1. Use Atom (or another editor) to make the change to the `index.html` file in -the top level directory. Change `Hello World!` to `Hello !` + the top level directory. Change `Hello World!` to `Hello !` 1. When you're finished, stage your file, commit your changes, and push to -GitHub using the following commands: - ```bash - git status - git add . - git commit -m "Initial Commit" - git push origin gh-pages - ``` + GitHub using the following commands: + `bash git status git add . git commit -m "Initial Commit" git push origin gh-pages` 1. Now go to your forked repository on GitHub (at - https://github.com/your-username/javascript-workbook). A little yellow box - should have popped up asking you to make a Pull Request. Click to review. + https://github.com/your-username/javascript-workbook). A little yellow box + should have popped up asking you to make a Pull Request. Click to review. 1. Click "Create Pull Request" -1. Every time you make a change *and push to GitHub*, this PR will automatically -update. No need to do it more than once. +1. Every time you make a change _and push to GitHub_, this PR will automatically + update. No need to do it more than once. #### Get latest workbook updates + 1. To get the latest code/homework/test updates, be sure to have a "clean -working directory" by committing or removing all of your changes. You check for -a "clean working environment" by running `git status` and making sure no files -show up. + working directory" by committing or removing all of your changes. You check for + a "clean working environment" by running `git status` and making sure no files + show up. 1. Run `git pull upstream gh-pages` ![Contributing workflow](https://docs.google.com/drawings/d/1WeKQxOHgPKfwjy_eKtlJO62Fu4XTCWFeqkAh1oIqICM/pub?w=960&h=720) ### Running the apps + Simply run `node path/to/file.js` example `node 01week/rockPaperScissors.js` ### Running Tests + Tests are a great way to make sure you code works the way you planned it would, and to make sure you don't break something in the future. We will be using them to test our understanding of the lesson. It's also our main way to assign grades @@ -75,8 +76,21 @@ for an assignment. To run a the tests on a file run `npm test path/to/file.js`, etc. ### Running the Linter + Simply run `npm run lint` #### Running the Server + 1. Run `npm start` 1. To break out of the server, press `ctrl` + `c` + +// for towers// +// 1. build a board. +// 3 verticle lines for the blocks to go through. +// 2. build the blocks. +// only 3 blocks +// each block should be slightly bigger than the last block +// for terminal app no colors. +// +// 3. set the rules for the game. +// 4. set a check for winner.