From 290c73f358c8a1f310dacaf9fc7ab260d6e65f0b Mon Sep 17 00:00:00 2001 From: Evgenii Meshcheriakov Date: Wed, 19 Oct 2022 09:58:59 +0300 Subject: [PATCH] Counter: setInit(): fix. Init can't be set to lower of down_lim or higher of up_lim --- StateHandler/src/Counter.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/StateHandler/src/Counter.cpp b/StateHandler/src/Counter.cpp index 571e6c8..39cec29 100644 --- a/StateHandler/src/Counter.cpp +++ b/StateHandler/src/Counter.cpp @@ -50,7 +50,15 @@ Counter::Counter (unsigned int down, unsigned int up) } void -Counter::setInit (unsigned int i) +Counter::setInit (unsigned int newInit) { - init = i; + if(newInit > up_lim){ + init = up_lim; + } + else if(newInit < down_lim){ + init = down_lim; + } + else{ + init = newInit; + } }