From 25bbedb05667418325fdcb9d08c6d459e2eb49ab Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Sun, 2 Feb 2020 11:35:18 -0500 Subject: [PATCH] Added ability for Stopwatch to be treated as a string for printing results --- mattrixwv/Stopwatch.java | 5 +++++ testStopwatch.java | 1 + 2 files changed, 6 insertions(+) diff --git a/mattrixwv/Stopwatch.java b/mattrixwv/Stopwatch.java index e20a573..47464c9 100644 --- a/mattrixwv/Stopwatch.java +++ b/mattrixwv/Stopwatch.java @@ -134,4 +134,9 @@ public class Stopwatch{ //Return the string return time; } + + @Override + public String toString(){ + return getStr(); + } } diff --git a/testStopwatch.java b/testStopwatch.java index 6f3a4fe..4cb722b 100644 --- a/testStopwatch.java +++ b/testStopwatch.java @@ -56,6 +56,7 @@ public class testStopwatch{ //Print the results 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()); if(!failed){