This site requires JavaScript, please enable it in your browser!
Greenfoot back
sophiaking
sophiaking wrote ...

2015/3/6

Counters

sophiaking sophiaking

2015/3/6

#
Once a counter is equal to zero how do you reset it
Super_Hippo Super_Hippo

2015/3/6

#
private int startValue = 20;

public Counter()
{
    reset();
}

public void act()
{
    //...
    if (value==0) reset();
}

private void reset()
{
    value = startValue;
    target = value;
    updateImage();
}
danpost danpost

2015/3/6

#
What does the counter do (and is it a class name or an object reference as used)? show what code you are trying.
sophiaking sophiaking

2015/3/8

#
THANK YOU IT WORKED
You need to login to post a reply.