Added ability for Stopwatch to be treated as a
string for printing results
This commit is contained in:
@@ -134,4 +134,9 @@ public class Stopwatch{
|
|||||||
//Return the string
|
//Return the string
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(){
|
||||||
|
return getStr();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public class testStopwatch{
|
|||||||
|
|
||||||
//Print the results
|
//Print the results
|
||||||
System.out.printf("The timer results in: %s\n", timer.getStr());
|
System.out.printf("The timer results in: %s\n", timer.getStr());
|
||||||
|
System.out.printf("The timer results in: " + timer + "\n");
|
||||||
System.out.printf("The timer results in: %f milliseconds\n", timer.getMilli());
|
System.out.printf("The timer results in: %f milliseconds\n", timer.getMilli());
|
||||||
|
|
||||||
if(!failed){
|
if(!failed){
|
||||||
|
|||||||
Reference in New Issue
Block a user