Skip to main content
fixed sentence fragment
Source Link
disc_code22
  • 418
  • 2
  • 10

In your resetTime function you are using the "+=" operator, which adds onto the variable's current value, rather than assigning it directly to the specified value. See this example to understand the difference between += and = operators:

int x = 1 //declaring int, initial value is 1
x += 5    // this evaluates to "x = x + 5", so x's value is now 6
x = 999   // this evaluates to "x = 999", setting x's value directly to 999

In the resetTime() method you are adding 0 to the current value of time, not setting time to 0. Change that line to use the = operator instead of the += operator and you should get the desired behavior.

In your resetTime function you are using the "+=" operator, which adds onto the variable's current value, rather than assigning it to. See this example to understand the difference between += and = operators:

int x = 1 //declaring int, initial value is 1
x += 5    // this evaluates to "x = x + 5", so x's value is now 6
x = 999   // this evaluates to "x = 999", setting x's value directly to 999

In the resetTime() method you are adding 0 to the current value of time, not setting time to 0. Change that line to use the = operator instead of the += operator and you should get the desired behavior.

In your resetTime function you are using the "+=" operator, which adds onto the variable's current value, rather than assigning it directly to the specified value. See this example to understand the difference between += and = operators:

int x = 1 //declaring int, initial value is 1
x += 5    // this evaluates to "x = x + 5", so x's value is now 6
x = 999   // this evaluates to "x = 999", setting x's value directly to 999

In the resetTime() method you are adding 0 to the current value of time, not setting time to 0. Change that line to use the = operator instead of the += operator and you should get the desired behavior.

improving code example and making answer more concise
Source Link
disc_code22
  • 418
  • 2
  • 10

In your resetTime function where you are resetting the timer you are using the +="+=" operator, which adds onto the variablesvariable's current value, rather than assigning it directly. If you want to set the value. See this example to zero you should useunderstand the difference between += and = operator to assign a value directly.

Exampleoperators:

int testIntx = 0;
testInt += 5;1 //testdeclaring int has had 5 added to it, test intinitial value is now 51
testIntx += 0;5    //test intthis hasevaluates hadto 0"x added= tox it+ 5", testso intx's value is stillnow 56
testIntx = 0;999   //test intthis hasevaluates beento set"x to= 0999", testsetting intx's value isdirectly nowto 0.999

In the resetTime() method you are adding 0 to the current value of time, not setting time to 0. Change that line to use the = operator instead of the += operator and you should get the desired behavior.

In your resetTime function where you are resetting the timer you are using the += operator, which adds onto the variables current value, rather than assigning it directly. If you want to set the value to zero you should use the = operator to assign a value directly.

Example:

int testInt = 0;
testInt += 5; //test int has had 5 added to it, test int value is now 5
testInt += 0; //test int has had 0 added to it, test int value is still 5
testInt = 0; //test int has been set to 0, test int value is now 0.

In the resetTime() method you are adding 0 to the current value of time, not setting time to 0. Change that line to use the = operator instead of the += operator and you should get the desired behavior.

In your resetTime function you are using the "+=" operator, which adds onto the variable's current value, rather than assigning it to. See this example to understand the difference between += and = operators:

int x = 1 //declaring int, initial value is 1
x += 5    // this evaluates to "x = x + 5", so x's value is now 6
x = 999   // this evaluates to "x = 999", setting x's value directly to 999

In the resetTime() method you are adding 0 to the current value of time, not setting time to 0. Change that line to use the = operator instead of the += operator and you should get the desired behavior.

Source Link
disc_code22
  • 418
  • 2
  • 10

In your resetTime function where you are resetting the timer you are using the += operator, which adds onto the variables current value, rather than assigning it directly. If you want to set the value to zero you should use the = operator to assign a value directly.

Example:

int testInt = 0;
testInt += 5; //test int has had 5 added to it, test int value is now 5
testInt += 0; //test int has had 0 added to it, test int value is still 5
testInt = 0; //test int has been set to 0, test int value is now 0.

In the resetTime() method you are adding 0 to the current value of time, not setting time to 0. Change that line to use the = operator instead of the += operator and you should get the desired behavior.