Example #1
0
  private static double calcularPagamento(String placa) {
    Box box;

    double tempo = 0;
    double valor = 0;

    box = localizarCarro(placa);
    if (box != null) {
      tempo = box.calcularTempoOcupacao();
      if (tempo < 0.5) valor = LIVRE;
      else if (tempo > 0.5 && tempo <= 1) {
        valor = HORA;
        return valor;
      } else if (tempo > 1) {
        valor = ((double) ((int) (tempo))) * HORAADIC + HORA;
        return valor;
      }
    }

    return valor;
  }
Example #2
0
  public static String emitirRecibo(String placa) {

    NumberFormat nf = NumberFormat.getCurrencyInstance();
    Box box = localizarCarro(placa);
    Carro carro = box.getCarro();

    String dadosCarro = carro.exibirDados();
    String dados =
        ("\n Número do Box: "
            + box.getNumero()
            + "\n Horário de Entrada: "
            + box.getHorarioEntrada().toString()
            + "\n Horário de Saída: "
            + box.getHorarioSaida().toString()
            + "\n Tempo de Ocupação: "
            + box.calcularTempoOcupacao()
            + "\n Valor a Pagar: "
            + nf.format(calcularPagamento(placa))
            + dadosCarro);

    box.setCarro(null);
    return (dados);
  }