diff --git a/app/app.ts b/app/app.ts
index e69de29..e5fcd9d 100644
--- a/app/app.ts
+++ b/app/app.ts
@@ -0,0 +1,22 @@
+import { Player } from './player';
+import { Game } from './game';
+import * as Helpers from './utility';
+
+let newGame: Game;
+
+// add click handler to the start game button
+document.getElementById('startGame')!.addEventListener('click', () => {
+ const player: Player = new Player();
+ player.name = Helpers.getValue('playername');
+
+ const problemCount: number = Number(Helpers.getValue('problemCount'));
+ const factor: number = Number(Helpers.getValue('factor'));
+
+ newGame = new Game(player, problemCount, factor);
+ newGame.displayGame();
+});
+
+// add click handler to the calculate score button
+document.getElementById('calculate')!.addEventListener('click', () => {
+ newGame.calculateScore();
+});
\ No newline at end of file
diff --git a/app/game.ts b/app/game.ts
new file mode 100644
index 0000000..4b4d2cb
--- /dev/null
+++ b/app/game.ts
@@ -0,0 +1,59 @@
+import { getValue } from './utility';
+import { Result } from './result';
+import { Player } from './player';
+import { Scoreboard as ResultPanel } from './scoreboard';
+
+export class Game {
+ private scoreboard: ResultPanel = new ResultPanel();
+
+ constructor(public player: Player, public problemCount: number, public factor: number) {
+ }
+
+ displayGame(): void {
+
+ // create the html for the current game
+ let gameForm: string = '';
+ for (let i = 1; i <= this.problemCount; i++) {
+ gameForm += '
';
+ }
+
+ // add the new game to the page
+ const gameElement: HTMLElement = document.getElementById('game')!;
+ gameElement.innerHTML = gameForm;
+
+ // enable the calculate score button
+ document.getElementById('calculate')!.removeAttribute('disabled');
+ }
+
+ calculateScore(): void {
+
+ let score: number = 0;
+
+ // loop through the text boxes and calculate the number that are correct
+ for (let i = 1; i <= this.problemCount; i++) {
+ const answer: number = Number(getValue('answer' + i));
+ if (i * this.factor === answer) {
+ score++;
+ }
+ }
+
+ // create a new result object to pass to the scoreboard
+ const result: Result = {
+ playerName: this.player.name,
+ score: score,
+ problemCount: this.problemCount,
+ factor: this.factor
+ };
+
+ // add the result and update the scoreboard
+ this.scoreboard.addResult(result);
+ this.scoreboard.updateScoreboard();
+
+ // disable the calculate score button
+ document.getElementById('calculate')!.setAttribute('disabled', 'true');
+ }
+}
\ No newline at end of file
diff --git a/app/person.ts b/app/person.ts
new file mode 100644
index 0000000..6932f75
--- /dev/null
+++ b/app/person.ts
@@ -0,0 +1,5 @@
+export interface Person {
+ name: string;
+ age?: number;
+ formatName: () => string;
+}
\ No newline at end of file
diff --git a/app/player.ts b/app/player.ts
new file mode 100644
index 0000000..b7b7099
--- /dev/null
+++ b/app/player.ts
@@ -0,0 +1,11 @@
+import { Person } from './person';
+
+export class Player implements Person {
+ name: string;
+ age: number;
+ highScore: number;
+
+ formatName() {
+ return this.name.toUpperCase();
+ }
+}
\ No newline at end of file
diff --git a/app/result.ts b/app/result.ts
new file mode 100644
index 0000000..3d631f6
--- /dev/null
+++ b/app/result.ts
@@ -0,0 +1,6 @@
+export interface Result {
+ playerName: string;
+ score: number;
+ problemCount: number;
+ factor: number;
+}
\ No newline at end of file
diff --git a/app/scoreboard.ts b/app/scoreboard.ts
new file mode 100644
index 0000000..b2f6fdb
--- /dev/null
+++ b/app/scoreboard.ts
@@ -0,0 +1,24 @@
+import { Result } from './result';
+
+export class Scoreboard {
+
+ private results: Result[] = [];
+
+ addResult(newResult: Result): void {
+ this.results.push(newResult);
+ }
+
+ updateScoreboard(): void {
+ let output: string = 'Scoreboard
';
+
+ for (let index = 0; index < this.results.length; index++) {
+ const result: Result = this.results[index];
+ output += '';
+ output += result.playerName + ': ' + result.score + '/' + result.problemCount + ' for factor ' + result.factor;
+ output += '
';
+ }
+
+ const scoresElement: HTMLElement = document.getElementById('scores')!;
+ scoresElement.innerHTML = output;
+ }
+}
\ No newline at end of file
diff --git a/app/tsconfig.json b/app/tsconfig.json
new file mode 100644
index 0000000..1c48055
--- /dev/null
+++ b/app/tsconfig.json
@@ -0,0 +1,12 @@
+{
+ "extends": "../tsconfig.base",
+ "compilerOptions": {
+ "removeComments": true,
+ "module": "commonjs",
+ "moduleResolution": "node",
+ "traceResolution": true
+ },
+ "files": [
+ "./app.ts"
+ ]
+}
\ No newline at end of file
diff --git a/app/utility.ts b/app/utility.ts
new file mode 100644
index 0000000..e41c4a1
--- /dev/null
+++ b/app/utility.ts
@@ -0,0 +1,11 @@
+function getInputValue(elementID: string): string {
+
+ const inputElement: HTMLInputElement = document.getElementById(elementID);
+ return inputElement.value;
+}
+
+function logger(message: string): void {
+ console.log(message);
+}
+
+export { getInputValue as getValue, logger }
\ No newline at end of file
diff --git a/index.html b/index.html
index c636518..4f52d1a 100644
--- a/index.html
+++ b/index.html
@@ -49,13 +49,13 @@
Scoreboard
- No scores yet
+ No scores yet
-
+