diff --git a/05week/checkers.js b/05week/checkers.js
index bed8c88bf..92f4476ef 100644
--- a/05week/checkers.js
+++ b/05week/checkers.js
@@ -7,55 +7,14 @@ const rl = readline.createInterface({
output: process.stdout
});
+function Checker() {
+ // Your code here
+}
+
class Board {
constructor() {
this.grid = [];
- this.checkers = [];
- this.redPiece = "X";
- this.blackPiece = "O";
- this.playerTrn = this.blackPiece;
- }
-
- initializeGrid() {
- for (let row = 0; row < 3; row++) {
- for (let column = 0; column < 8; column++) {
- if (column % 2 === 1 && row % 2 === 0) {
- this.grid[row][column] = this.redPiece;
- this.checkers.push(this.redPiece);
- } else if (column % 2 === 0 && row % 2 === 1) {
- this.grid[row][column] = this.redPiece;
- this.checkers.push(this.redPiece);
- }
- }
- }
- for (let row = 5; row < 8; row++) {
- for (let column = 0; column < 8; column++) {
- if (column % 2 === 1 && row % 2 === 0) {
- this.grid[row][column] = this.blackPiece;
- this.checkers.push(this.blackPiece);
- } else if (column % 2 === 0 && row % 2 === 1) {
- this.grid[row][column] = this.blackPiece;
- this.checkers.push(this.blackPiece);
- }
- }
- }
}
- selectChecker(row, col) {
- return this.grid[row][col];
- }
-
- killChecker(position) {
- let checker = this.selectChecker(position[0], position[1]);
- let indexChecker = this.checkers.indexOf(checker);
- this.checkers.splice(indexChecker, 1);
-
- this.grid[position[0]][position[1]] = null;
- }
-
- // important numbers
- // 11 -11 9 -9 1 4 jump
- // -22 22 -18 18 2 jump
-
// method that creates an 8x8 array, filled with null values
createGrid() {
// loop to create the 8 rows
@@ -78,7 +37,7 @@ class Board {
// if the location is "truthy" (contains a checker piece, in this case)
if (this.grid[row][column]) {
// push the symbol of the check in that location into the array
- rowOfCheckers.push(this.grid[row][column]);
+ rowOfCheckers.push(this.grid[row][column].symbol);
} else {
// just push in a blank space
rowOfCheckers.push(" ");
@@ -91,8 +50,9 @@ class Board {
}
console.log(string);
}
+
+ // Your code here
}
-// Your code here
class Game {
constructor() {
@@ -100,22 +60,6 @@ class Game {
}
start() {
this.board.createGrid();
- this.board.initializeGrid();
- }
- moveChecker(start, end) {
- const startX = parseInt(start[0]);
- const startY = parseInt(start[1]);
- const endX = parseInt(end[0]);
- const endY = parseInt(end[1]);
-
- const checker = this.board.selectChecker(start[0], start[1]);
-
- this.board.grid[endX][endY] = checker;
- this.board.grid[startX][startY] = null;
-
- if (Math.sqrt((endX - startX) ^ (2 + (endY - startY)) ^ 2) >= 2) {
- this.board.killChecker([(endX + startX) / 2, (endY + startY) / 2]);
- }
}
}
@@ -129,7 +73,6 @@ function getPrompt() {
});
}
-//dont change below
const game = new Game();
game.start();
diff --git a/07week/API.html b/07week/API.html
deleted file mode 100644
index 3cce4d72c..000000000
--- a/07week/API.html
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- Fetch
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/07week/api.js b/07week/api.js
deleted file mode 100644
index 1d2e7cf5a..000000000
--- a/07week/api.js
+++ /dev/null
@@ -1,62 +0,0 @@
-// // document.getElementById("getAPI").addEventListener('click', getAPI)
-// const ul = document.getElementById("authors"); // Get the list where we will place our authors
-// const url = "https://randomuser.me/api/?results=10";
-// let data = {
-// name: "Sara"
-// };
-// // The parameters we are gonna pass to the fetch function
-// let fetchData = {
-// method: "POST",
-// body: data,
-// headers: new Headers()
-// };
-// fetch(url, fetchData);
-// function createNode(element) {
-// return document.createElement(element); // Create the type of element you pass in the parameters
-// }
-
-// function append(parent, el) {
-// return parent.appendChild(el); // Append the second parameter(element) to the first one
-// }
-
-// // function getAPI(){
-// fetch("https://randomuser.me/api/")
-// .then(res => res.json())
-// .then(data => {
-// let authors = data.results; // Get the results
-// return authors.map(function(author) {
-// // Map through the results and for each run the code below
-// let li = createNode("li"), // Create the elements we need
-// img = createNode("img"),
-// span = createNode("span");
-// img.src = author.picture.medium; // Add the source of the image to be the src of the img element
-// span.innerHTML = `${author.name.first} ${author.name.last}`; // Make the HTML of our span to be the first and last name of our author
-// append(li, img); // Append all our elements
-// append(li, span);
-// append(ul, li);
-// return authors
-// });
-// });
-
-// document.getElementById("getAPI").innerHTML = output;
-
-// document.getElementById("getAPI").addEventListener("click", getAPI);
-
-function getAPI() {
- fetch("https://randomuser.me/api/")
- .then((res) => res.json())
- .then((data) => {
- let output = "