Package net.n1da.dev.euler.core
Class Problem
- java.lang.Object
-
- net.n1da.dev.euler.core.Problem
-
- All Implemented Interfaces:
Solvable
- Direct Known Subclasses:
PE0001
,PE0002
,PE0003
,PE0004
,PE0005
,PE0006
,PE0007
,PE0008
,PE0009
,PE0010
,PE0011
,PE0012
,PE0013
,PE0014
,PE0015
,PE0016
,PE0017
,PE0018
,PE0019
,PE0020
,PE0021
,PE0022
,PE0023
,PE0024
,PE0025
,PE0026
,PE0027
,PE0028
,PE0029
,PE0030
,PE0031
,PE0032
,PE0033
,PE0035
,PE0036
,PE0037
,PE0038
,PE0039
,PE0040
,PE0041
,PE0042
,PE0043
,PE0044
,PE0045
,PE0046
,PE0047
,PE0048
,PE0049
,PE0050
,PE0051
,PE0052
,PE0053
,PE0054
,PE0055
,PE0056
,PE0057
,PE0058
,PE0059
,PE0060
,PE0061
,PE0062
,PE0063
,PE0064
,PE00XX
public abstract class Problem extends java.lang.Object implements Solvable
The base class for all Project Euler problems.- Since:
- 11.04.2015 11:39:24
- Author:
- Nico Danneberg
-
-
Field Summary
Fields Modifier and Type Field Description private long
end
The time in nanoseconds when the solving process got finished.protected int
number
The number of this problem.private long
start
The time in nanoseconds when the solving process got started.protected java.lang.String
title
The title of this problem.
-
Method Summary
Modifier and Type Method Description void
finish()
Standard implementation of the finishing method.java.lang.String
getResult()
This method should be called by an external execution process.double
getRuntime(int p)
void
prepare()
Standard implementation of the preparing method.private void
start()
Stores the current system's time in nanoseconds intostart
.private void
stop()
stores the current system's time nanoseconds intoend
.java.lang.String
toString()
It just returns thenumber
of this problem asstring
representation.
-
-
-
Field Detail
-
number
protected int number
The number of this problem.
-
title
protected java.lang.String title
The title of this problem.
-
start
private long start
The time in nanoseconds when the solving process got started.
-
end
private long end
The time in nanoseconds when the solving process got finished.
-
-
Method Detail
-
getResult
public java.lang.String getResult()
This method should be called by an external execution process. It does internally the following steps by calling the necessary methods:prepare
the problem solvingstart
the internal timersolve
the problemstop()
the internal timerfinish
the solving process
string
given bySolvable.solve()
is returned.- Returns:
- the result of this problem as
string
-
getRuntime
public double getRuntime(int p)
Calculates the runtime needed to solve this problem as difference ofend
andstart
. Since the time is stored in nanoseconds a divider - a power of 1.000 - can be used.- Parameters:
p
- - the power of 1000 to transform the time (use 0 to get nanoseconds)- Returns:
- - the runtime of the execution in the wanted format
-
start
private void start()
Stores the current system's time in nanoseconds intostart
.
-
stop
private void stop()
stores the current system's time nanoseconds intoend
.
-
prepare
public void prepare()
Standard implementation of the preparing method. It justprints an info
with thenumber
andtitle
. It can be overridden by subclasses if needed.
-
finish
public void finish()
Standard implementation of the finishing method. It justprints an info
with thenumber
. It can be overridden by subclasses if needed.
-
-