Permalink
Browse files

Fixed errors caused by const keyword

  • Loading branch information...
1 parent 2342fab commit 7d730625bf8dc9c64a480399839744f2a72f288d @thomasfredericks committed Jul 1, 2015
Showing with 28 additions and 6 deletions.
  1. +12 −2 Chrono.cpp
  2. +3 −2 Chrono.h
  3. +11 −1 LightChrono.cpp
  4. +2 −1 LightChrono.h
View
@@ -86,14 +86,24 @@ bool Chrono::isRunning() const {
void Chrono::delay(unsigned long time) {
time += elapsed();
- while (!passed(time));
+ while (!hasPassed(time));
}
unsigned long Chrono::elapsed() const {
return _offset + (_isRunning ? (_getTime() - _startTime) : 0);
}
-bool Chrono::hasPassed(unsigned long timeout, bool restartIfPassed) const
+bool Chrono::hasPassed(unsigned long timeout)
+{
+ if (elapsed() >= timeout) {
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+bool Chrono::hasPassed(unsigned long timeout, bool restartIfPassed)
{
if (elapsed() >= timeout) {
if (restartIfPassed)
View
@@ -88,8 +88,9 @@ class Chrono
/// Returns the elapsed time since start (in milliseconds).
unsigned long elapsed() const;
- /// Returns true iff elapsed time has passed given timeout.
- bool hasPassed(unsigned long timeout, bool restartIfPassed=false) const;
+ /// Returns true if elapsed time has passed given timeout.
+ bool hasPassed(unsigned long timeout);
+ bool hasPassed(unsigned long timeout, bool restartIfPassed);
/// Returns true iff the chronometer is currently running.
bool isRunning() const;
View
@@ -46,7 +46,17 @@ unsigned long LightChrono::elapsed() const {
return (millis() - _startTime);
}
-bool Chrono::hasPassed(unsigned long timeout, bool restartIfPassed) const
+bool LightChrono::hasPassed(unsigned long timeout)
+{
+ if (elapsed() >= timeout) {
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+bool LightChrono::hasPassed(unsigned long timeout, bool restartIfPassed)
{
if (elapsed() >= timeout) {
if (restartIfPassed)
View
@@ -55,7 +55,8 @@ class LightChrono
unsigned long elapsed() const;
/// Returns true iff elapsed time has passed given timeout.
- bool hasPassed(unsigned long timeout, bool restartIfPassed=false) const;
+ bool hasPassed(unsigned long timeout) ;
+ bool hasPassed(unsigned long timeout, bool restartIfPassed) ;
};
#endif

0 comments on commit 7d73062

Please sign in to comment.