void main() {

    Fruit[] fruits = stay();
    while (getNumberOfCapturedFruits() + 
           getNumberOfNotCapturedFruits()  < 100) {
        Fruit fruit = calcFruit(fruits);
        if (fruit != null) {
            if (canCapture(fruit)) {
               captureFruit(); 
               fruits = stay();
            } else if (fruit.column == getColumn()) {
                fruits = stay();
            } else if (fruit.column < getColumn()) {
                fruits = left();
            } else {
                fruits = right();
            }
        } else {
            fruits = stay();
        }
    }
}

Fruit calcFruit(Fruit[] fruits) {
    if (fruits.length == 0) {
        return null;
    } else {
        return fruits[0];
    }
}

boolean canCapture(Fruit fruit) {
    return getColumn() == fruit.column && 
           getRow() == fruit.row;
}
