"mazin" <mazin_ghafadgi@hotmail.com> wrote:
>
>"Andy" <andrew.constable@ntlworld.com> wrote:
>>
>>Can anyone help!
>>
>>I am trying to use a if else loop and it does not seem to work.
>>What I am trying to do is create a class called maxNumber with all methods
>>in for a test class which calls the maxNumber class to return the values.The
>>code that I am having problems with is
>>below.
>>
>> //Updates the maximum value to the value specified
>> //if necessary - if the value is greater than the
>> //current maxValue.
>>
>> public void setMaxValue(int value)
>> {
>> if (value > maxValue)
>> {
>> maxValue = value;
>> }
>> else
>> {
>> maxValue = maxValue;
>> }
>> }
>>I want the maxValue to be updated by the value in the parameter only if

>the
>>value is above the current maxValue.
>>Help!!
>>
>>Andy

>
>
> try to use else if { it is more powerfull than using the esle on it own
>}
>
>
>
> public void setMaxValue(int value)
> {
> if (value > maxValue)
> {
> maxValue = value;
> }
> else if ( value < maxvalue )
> {
> maxValue = maxValue;
> }
> }
>
>

try this

> public int setMaxValue(int value)
>> {
>> if (value > maxValue)
>> {
>> maxValue = value;
>> return maxValue;

}
>> else
>> {
>> maxValue = maxValue;
>> return maxValue

}
>> }


>