Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 106 | espaco | 1 | package br.com.ec.domain.dto; |
| 2 | |||
| 3 | public class CarroDTO implements Comparable<CarroDTO> { |
||
| 4 | |||
| 5 | private Integer colocacao; |
||
| 6 | private Integer identificador; |
||
| 7 | private Integer altura = 0; |
||
| 8 | private Double distancia; |
||
| 9 | private Double percentual; |
||
| 10 | private String descricao; |
||
| 11 | |||
| 12 | private Long sequencialLoja; |
||
| 13 | private Double metaDiaria; |
||
| 14 | private Double vendasDoDia; |
||
| 15 | |||
| 16 | public CarroDTO() { |
||
| 17 | setDistancia(new Double(0)); |
||
| 18 | } |
||
| 19 | |||
| 20 | public Integer getColocacao() { |
||
| 21 | return colocacao; |
||
| 22 | } |
||
| 23 | public void setColocacao(Integer colocacao) { |
||
| 24 | this.colocacao = colocacao; |
||
| 25 | } |
||
| 26 | |||
| 27 | public Integer getIdentificador() { |
||
| 28 | return identificador; |
||
| 29 | } |
||
| 30 | public void setIdentificador(Integer identificador) { |
||
| 31 | this.identificador = identificador; |
||
| 32 | } |
||
| 33 | |||
| 34 | public Integer getAltura() { |
||
| 35 | return altura; |
||
| 36 | } |
||
| 37 | public void setAltura(Integer altura) { |
||
| 38 | this.altura = altura; |
||
| 39 | } |
||
| 40 | |||
| 41 | public Double getDistancia() { |
||
| 42 | return distancia; |
||
| 43 | } |
||
| 44 | public void setDistancia(Double distancia) { |
||
| 45 | this.distancia = distancia; |
||
| 46 | } |
||
| 47 | |||
| 48 | public void setPercentual(Double percentual) { |
||
| 49 | this.percentual = percentual; |
||
| 50 | } |
||
| 51 | public Double getPercentual() { |
||
| 52 | return percentual; |
||
| 53 | } |
||
| 54 | |||
| 55 | public String getDescricao() { |
||
| 56 | return descricao; |
||
| 57 | } |
||
| 58 | public void setDescricao(String descricao) { |
||
| 59 | this.descricao = descricao; |
||
| 60 | } |
||
| 61 | |||
| 62 | public Long getSequencialLoja() { |
||
| 63 | return sequencialLoja; |
||
| 64 | } |
||
| 65 | public void setSequencialLoja(Long sequencialLoja) { |
||
| 66 | this.sequencialLoja = sequencialLoja; |
||
| 67 | } |
||
| 68 | |||
| 69 | public Double getMetaDiaria() { |
||
| 70 | return metaDiaria; |
||
| 71 | } |
||
| 72 | public void setMetaDiaria(Double metaDiaria) { |
||
| 73 | this.metaDiaria = metaDiaria; |
||
| 74 | } |
||
| 75 | |||
| 76 | public Double getVendasDoDia() { |
||
| 77 | return vendasDoDia; |
||
| 78 | } |
||
| 79 | public void setVendasDoDia(Double vendasDoDia) { |
||
| 80 | this.vendasDoDia = vendasDoDia; |
||
| 81 | } |
||
| 82 | |||
| 83 | @Override |
||
| 84 | public int hashCode() { |
||
| 85 | final int prime = 31; |
||
| 86 | int result = 1; |
||
| 87 | result = prime * result + ((identificador == null) ? 0 : identificador.hashCode()); |
||
| 88 | return result; |
||
| 89 | } |
||
| 90 | |||
| 91 | @Override |
||
| 92 | public boolean equals(Object obj) { |
||
| 93 | if (this == obj) |
||
| 94 | return true; |
||
| 95 | if (obj == null) |
||
| 96 | return false; |
||
| 97 | if (getClass() != obj.getClass()) |
||
| 98 | return false; |
||
| 99 | CarroDTO other = (CarroDTO) obj; |
||
| 100 | if (identificador == null) { |
||
| 101 | if (other.identificador != null) |
||
| 102 | return false; |
||
| 103 | } else if (!identificador.equals(other.identificador)) |
||
| 104 | return false; |
||
| 105 | return true; |
||
| 106 | } |
||
| 107 | |||
| 108 | @Override |
||
| 109 | public int compareTo(CarroDTO carroDTO) { |
||
| 110 | return carroDTO.getDistancia().compareTo(this.distancia); |
||
| 111 | } |
||
| 112 | |||
| 113 | public void calcularPercentual() { |
||
| 114 | Double percentual = ((getVendasDoDia() * 100) / getMetaDiaria()); |
||
| 115 | if (percentual > 100) { |
||
| 116 | setDistancia(new Double(1000)); |
||
| 117 | } else { |
||
| 118 | setDistancia(percentual * 10); |
||
| 119 | } |
||
| 120 | setPercentual(percentual); |
||
| 121 | } |
||
| 122 | |||
| 123 | } |