Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 44 additions & 5 deletions 05week/checkers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,29 @@ const rl = readline.createInterface({
output: process.stdout
});

// code plan
// movechecker(s,e)
// use .split for start and end
// make the end equal the start in side function
// islegal function is necessary
// how to kill a checker
// use object to describe board

function Checker() {
// Your code here
function Checker(color) {
if (color === 'white') {
this.symbol = String.fromCharCode(0x125CF);
this.color = 'white';
}
else {
this.symbol = String.fromCharCode(0x125CB);
this.color = 'black';
}
}

function Board() {
this.grid = [];
// creates an 8x8 array, filled with null values
this.createGrid = function() {
this.createGrid = () => {
// loop to create the 8 rows
for (let row = 0; row < 8; row++) {
this.grid[row] = [];
Expand All @@ -27,7 +41,7 @@ function Board() {
};

// prints out the board
this.viewGrid = function() {
this.viewGrid = () => {
// add our column numbers
let string = " 0 1 2 3 4 5 6 7\n";
for (let row = 0; row < 8; row++) {
Expand All @@ -51,17 +65,42 @@ function Board() {
}
console.log(string);
};
this.populateGrid = () => {
// loops through the 8 rows
for (let row = 0; row < 8; row++) {
// ignores rows which should be empty
if (row === 3 || row === 4) continue;
// loops through the 8 columns
for (let col = 0; col < 8; col++) {
// sets current color based on the current row
let color = (row < 3 ? 'white' : 'black');
// alternates cells to populate with either white or black checkers
// then pushes checker to array named checkers
if (row % 2 === 0 && col % 2 === 1) {
this.grid[row][col] = new Checker(color);
} else if (row % 2 === 1 && col % 2 === 0) {
this.grid[row][col] = new Checker(color);
}
}
}
};

// Your code here
}


function Game() {

this.board = new Board();

this.start = function() {
this.board.createGrid();
// Your code here
this.board.populateGrid();
};
// your code here
this.moveChecker = (whichPiece, toWhere) => {
whichPiece.Split
}
}

function getPrompt() {
Expand Down
21 changes: 21 additions & 0 deletions 07week/react-tictactoe/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
/node_modules

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
2,229 changes: 2,229 additions & 0 deletions 07week/react-tictactoe/README.md

Large diffs are not rendered by default.

Loading