Updated to use new library layout

This commit is contained in:
2021-07-14 15:38:17 -04:00
parent ad2e948a42
commit b5c1df010f
39 changed files with 316 additions and 493 deletions

View File

@@ -1,11 +1,11 @@
//ProjectEulerTS/Problems/Problem.ts
//Matthew Ellison
// Created: 10-18-20
//Modified: 10-18-20
//Modified: 07-14-21
//What is the sum of all the multiples of 3 or 5 that are less than 1000
//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/typescriptClasses
/*
Copyright (C) 2020 Matthew Ellison
Copyright (C) 2021 Matthew Ellison
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -21,6 +21,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Stopwatch } from "../../../Typescript/typescriptClasses/Stopwatch";
import { Unsolved } from "../Unsolved";
@@ -36,24 +37,26 @@ export abstract class Problem{
this.description = description;
this.solved = false;
}
//Make sure the problem has been solved and throw an exception if not
protected solvedCheck(str: string): void{
if(!this.solved){
throw new Unsolved("You must solve the problem before you can see the " + str);
}
}
//Gets
getDescription(): string{
public getDescription(): string{
return this.description;
}
//Returns the result of solving the problem
public abstract getResult(): string;
//Returns the time taken to run the problem as a string
public getTime(): string{
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("time it took to run the algorithm");
return this.timer.getStr();
}
//Returns the timer as a stopwatch
public getTimer(): Stopwatch{
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("timer");
return this.timer;
}
//Solve the problem
@@ -63,4 +66,4 @@ export abstract class Problem{
this.timer.reset();
this.solved = false;
}
}
}