我如何将此代码转换为循环?

use*_*447 0 java loops if-statement

public Bee anotherDay(){
    flower = garden.findFlower();
    int pol = 5;
    bool=flower.extractPollen(pol);
    if(bool=true){  
        hive.addPollen(pol);
    }else{
        ++pol;
        bool=flower.extractPollen(pol);

        if(bool=true){  
            hive.addPollen(pol);
        }else{
            ++pol; //etc.
        } 
    }
Run Code Online (Sandbox Code Playgroud)

该代码的重点是:

1)use the findFlower() method on garden ot return a flower
2)use the extract pollen method on the flower with 5 as the initial paramater
3)If there isn't 5 pollen in the flower, the method returns false so try again with 4
4)If there isn't 4 try with 3 etc. until 0. 
Run Code Online (Sandbox Code Playgroud)

我正在考虑使用for循环,但我不知道如果方法成功并且返回true,如何突破它,所以我不会继续从花中获得5 + 4 + 3 + 2 + 1花粉.

Sam*_*ica 5

flower = garden.findFlower();
for(int pol=5; pol>0; pol--)
{
    if(flower.extractPollen(pol) {
        hive.addPollen(pol);
        break;
    }
}
Run Code Online (Sandbox Code Playgroud)