diff --git a/Stopwatch.py b/Stopwatch.py index 3c9626c..a9b7b49 100644 --- a/Stopwatch.py +++ b/Stopwatch.py @@ -155,3 +155,12 @@ class Stopwatch: #Return the string return timeString + + def __str__(self): + return self.getString() + + def __add__(self, other): + return self.getString() + other + + def __radd__(self, other): + return other + self.getString() diff --git a/testStopwatch.py b/testStopwatch.py index 7508347..7197ec3 100644 --- a/testStopwatch.py +++ b/testStopwatch.py @@ -73,6 +73,7 @@ else: #Print the results print("\nHere is a printing of the different times, starting with the string:") +print("It took " + timer + " to run this algorithm") print("It took " + timer.getString() + " to run this algorithm") print("It took " + str(timer.getNanoseconds()) + " nanoseconds to run this algorithm") print("It took " + str(timer.getMicroseconds()) + " microseconds to run this algorithm")