Como fazer estes Array? Fiz metade e o restante não consegui

Fiz uma parte deste, porem não sei como vou colocar no código para alugar alguma coisa… Se alguém souber, me ajude.

Consegui fazer: Inserir, Remover.
Não consegui: Alugar, Devolver, Listar.

package br.edu.ifmt.estrutura.dados.dominio;

public class Imobiliaria {

private int quantidade;
Imovel definir[] = new Imovel[20];
public boolean Inserir(Imovel imovel) {
    for (int i = 0; i < definir.length; i++) {
        if (definir[i] == null) {
            this.definir[i] = imovel;
            return true;
        }
    }
    return false;
}
public boolean Remover(Imovel imovel) {
    for (int i = 0; i < definir.length; i++) {
        if (definir[i] != null) {
            this.definir[i] = null;
            return true;
        } else {
            return false;
        }
    }
    return false;
}

public boolean Alugar(Imovel imovel){
    
}

public boolean Devolver(Imovel imovel){
    
}

public String listarImoveis(String filtro){
    for (int i = 0; i < definir.length; i++){
        if 
    }
}

}

Só uma observação “Opcional” você poderia melhorar o seu algoritmo, por exemplo: Se teu Array estiver 500 posições ele vai percorrer toda posição no começo a até encontrar uma posição null? Você assim para melhorar até da quantidade de linha.

package br.edu.ifmt.estrutura.dados.dominio;

public class Imobiliaria {

  private int quantidade;
  Imovel [] definir; 

  public Imobiliaria(){
   this.definir = new Imovel[100];
   this.quantidade = 0; 
  }

   public boolean Inserir(Imovel imovel) {
        if (this.tamanho < definir.leght) {
                this.definir[this.quantidade] = imovel;
                this.quantidade++; 
                return true;
            }
        }
        return false;
    }

Nossa que ótimo!
Farei essas alterações no código;
Obrigado :slight_smile: