Started verification tests

This commit is contained in:
2022-12-04 23:27:25 -05:00
parent 62a8589364
commit 7a3f2214f8
20 changed files with 721 additions and 7 deletions

View File

@@ -19,7 +19,7 @@
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.mattrixwv.project_euler;
package com.mattrixwv.project_euler.exceptions;
public class Unsolved extends RuntimeException{

View File

@@ -24,14 +24,13 @@ package com.mattrixwv.project_euler.problems;
import com.mattrixwv.Stopwatch;
import com.mattrixwv.exceptions.InvalidResult;
import com.mattrixwv.project_euler.Unsolved;
import com.mattrixwv.project_euler.exceptions.Unsolved;
public abstract class Problem{
//Variables
//Instance variables
protected final Stopwatch timer = new Stopwatch(); //To time how long it takes to run the algorithm
protected Stopwatch timer = new Stopwatch(); //To time how long it takes to run the algorithm
private final String description; //Holds the description of the problem
protected boolean solved; //Shows whether the problem has already been solved
@@ -62,11 +61,14 @@ public abstract class Problem{
}
return timer;
}
void solvedCheck(String str){
protected void solvedCheck(String str){
if(!solved){
throw new Unsolved("You must solve the problem before you can see the " + str);
}
}
public boolean getSolved(){
return solved;
}
//Solve the problem
public abstract void solve() throws InvalidResult;
//Reset the problem so it can be run again

View File

@@ -24,7 +24,7 @@ package com.mattrixwv.project_euler.problems;
import com.mattrixwv.exceptions.InvalidResult;
import com.mattrixwv.project_euler.Unsolved;
import com.mattrixwv.project_euler.exceptions.Unsolved;
public class Problem17 extends Problem{

View File

@@ -23,7 +23,7 @@
package com.mattrixwv.project_euler.problems;
import com.mattrixwv.project_euler.Unsolved;
import com.mattrixwv.project_euler.exceptions.Unsolved;
public class Problem9 extends Problem{