diff --git a/07week/ticTacToe/script.js b/07week/ticTacToe/script.js
index d0bc4bd52..0ced0dd1c 100644
--- a/07week/ticTacToe/script.js
+++ b/07week/ticTacToe/script.js
@@ -1,28 +1,48 @@
'use strict';
class TicTacToe extends React.Component {
+
constructor(props) {
super(props);
+ this.state = {
+ turn: 'X',
+ };
+ this.message = '';
}
+ handleClick=(cell)=>{
+ const state = {...this.state};
+ const // this.state.turn? 'X' : 'O';
+ if (!state[cell]) {
+ state[cell] = this.state.turn;
+ state['turn'] = this.state.turn === 'X'? 'O' : 'X'; // Switch between X and O
+ this.message = '';
+ } else {
+ this.message = 'Square occupied. Please select a different square';
+ }
+ // toggleTurn();
+ // this.state.turn? 'X' : 'O';
+ this.setState(state)
+ };
render() {
return (
-
-
-
+
this.handleClick('cell0')}>{this.state.cell0}
+
this.handleClick('cell1')}>{this.state.cell1}
+
this.handleClick('cell2')}>{this.state.cell2}
-
-
-
+
this.handleClick('cell3')}>{this.state.cell3}
+
this.handleClick('cell4')}>{this.state.cell4}
+
this.handleClick('cell5')}>{this.state.cell5}
-
-
-
+
this.handleClick('cell6')}>{this.state.cell6}
+
this.handleClick('cell7')}>{this.state.cell7}
+
this.handleClick('cell8')}>{this.state.cell8}
+
{this.message}
);
}
diff --git a/07week/towersOfHanoi/Block.js b/07week/towersOfHanoi/Block.js
new file mode 100644
index 000000000..fdb3a8e3a
--- /dev/null
+++ b/07week/towersOfHanoi/Block.js
@@ -0,0 +1,11 @@
+// import React from 'react';
+
+// This functional component renders a block. We pass the size
+// of the block in props.
+const Block = (props) => {
+ return (
+
+ );
+};
+
+// export default Block;
diff --git a/07week/towersOfHanoi/Pop.js b/07week/towersOfHanoi/Pop.js
new file mode 100644
index 000000000..fad743029
--- /dev/null
+++ b/07week/towersOfHanoi/Pop.js
@@ -0,0 +1,9 @@
+// This functional component renders the Popped block line.
+const Pop = (props) => {
+ return (
+
+ );
+};
diff --git a/07week/towersOfHanoi/Stack.js b/07week/towersOfHanoi/Stack.js
new file mode 100644
index 000000000..e088f8327
--- /dev/null
+++ b/07week/towersOfHanoi/Stack.js
@@ -0,0 +1,28 @@
+// import React from 'react';
+// import Block from './Block.js';
+
+// This functional component renders the Stacks. It uses an array map to display
+// all the blocks assigned in stacks arrays.
+const Stack = (props) => {
+
+ // const updateMe = ;
+
+ return (
+ props.handleStackClick(props.id)}
+ >
+ {
+ props.blocks.map((blockSize,index) =>
+
+ )
+ }
+
+ );
+
+};
+
+// export default Stack;
diff --git a/07week/towersOfHanoi/index.html b/07week/towersOfHanoi/index.html
index 37d057527..9955c4445 100644
--- a/07week/towersOfHanoi/index.html
+++ b/07week/towersOfHanoi/index.html
@@ -10,6 +10,11 @@
+
+
+
+
+