views:

148

answers:

1

Below is part of some code which displays a gauge which shows the progress from 0 - 100 of a word counter, however i am unsure how to code the if statement to display some text to show a successful count. I have had a go at the if statement " if gg_Progress.value = 100 " which i know is wrong, does anyone know what it should say. Thanks

public void SetGauge(int value) {
    this.gg_Progress.setValue(value);
}


public void GaugeCheck () {

    if gg_Progress.value = 100 {

        string_Progress.setText("The number of words have been successfully counted");
    }
}
A: 
if (this.gg_Progress.getValue() == 100) {
mopoke
Doesnt work i get an error saying "(" ")" expected..
Jaron787
Sorry my mistake, it cant find the symbol variable value..
Jaron787
Try using the accessor getValue() instead... Updated answer.
mopoke
Ok that seems to work, however i now have another problem. How do you call that method only when it has finished counting because I have included an else statement stating that a it has not successfully counted and it just continually prints that.
Jaron787
I'm not sure I understand what you're doing with the else statement - what is the purpose of it?Why not set the message that it's not completed when you initialise, keep checking as you currently are and then change the message on completion?
mopoke
The problem is, that this method is being called before the word counter method has finished, so before it reaches 100 it prints the else statement. If i get rid of the else statement nothing happens. Surely it only checks once doesnt it?
Jaron787