Example #1
0
 public Boolean acuarioExiste(Acuario acuario) {
   Boolean btmp = false;
   for (int i = 0; i < this.acuarios.size(); i++) {
     if (this.acuarios.get(i).getIdAcuario() == acuario.getIdAcuario()) {
       btmp = true;
     }
   }
   return btmp;
 }
Example #2
0
  public void quitarAcuario(Acuario acuario) {
    Integer itmp = null;
    if (acuarioExiste(acuario)) {
      for (int i = 0; i < this.acuarios.size(); i++) {
        if (this.acuarios.get(i).getIdAcuario() == acuario.getIdAcuario()) {
          itmp = i;
        }
      }
    }

    if (itmp != null) {
      this.acuarios.remove(itmp);
    }
  }
Example #3
0
  public boolean especieCompatibleAcuario(Especie especie, Acuario acuario) {
    boolean compatible = false;
    boolean ghCompatible = false;
    boolean khCompatible = false;
    boolean phCompatible = false;
    boolean temperaturaCompatible = false;
    boolean tipoAguaCompatible = false;

    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();

    Especie esp = (Especie) session.get(Especie.class, especie.getIdEspecie());
    Acuario acu = (Acuario) session.get(Acuario.class, acuario.getIdAcuario());
    System.out.println(
        "Agua de especie =" + esp.getTipoAgua() + ". Agua de acuario=" + acu.getTipoAgua());

    if (esp.getTipoAgua().equals(acu.getTipoAgua())) {
      tipoAguaCompatible = true;

      for (int i = 0; i <= 3; i++) {
        if ((esp.getParametros().get(i).getMinimo() <= acu.getParametros().get(i).getMinimo())
            & (esp.getParametros().get(i).getMaximo() >= acu.getParametros().get(i).getMaximo())) {

          switch (i) {
            case 0:
              ghCompatible = true;
              break;

            case 1:
              khCompatible = true;
              break;

            case 2:
              phCompatible = true;
              break;

            case 3:
              temperaturaCompatible = true;
              break;
          }
        }
      }
    }

    compatible =
        ghCompatible & khCompatible & phCompatible & temperaturaCompatible & tipoAguaCompatible;
    session.getTransaction().commit();
    return compatible;
  }