Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Criar a classe FichaAluguel colar abaixo do packpage */
- /**
- *
- * @author Professor Hercio Neto
- */
- public class FichaAluguel {
- private Double valorDiaria;
- private Double valorAluguelKm;
- private Double valorDias;
- private Double valorKms;
- private Integer kms;
- private Integer dias;
- private String tipoVeiculo;
- public Double getValorDiaria() {
- return valorDiaria;
- }
- public void setValorDiaria(Double valorDiaria) {
- this.valorDiaria = valorDiaria;
- }
- public Double getValorAluguelKm() {
- return valorAluguelKm;
- }
- public void setValorAluguelKm() {
- this.valorAluguelKm = this.getValorKms()*this.getKms();
- }
- public Double getValorDias() {
- return valorDias;
- }
- public void setValorDias() {
- Double valorDias = this.valorDiaria*this.getDias();
- this.valorDias = valorDias;
- }
- public Double getValorKms() {
- return valorKms;
- }
- public void setValorKms() {
- Double valorKm=0d;
- if ("POPULAR".equals(this.getTipoVeiculo())) {
- this.setValorDiaria(90.00d);
- if (this.getKms() >=100) {
- valorKm = 0.20d; } else {
- valorKm = 0.10d;
- }
- }
- if ("LUXO".equals(this.getTipoVeiculo())) {
- this.setValorDiaria(150.00d);
- if (this.getKms() >=200) {
- valorKm = 0.30d; } else {
- valorKm = 0.25d;
- }
- }
- this.valorKms = valorKm;
- }
- public Integer getKms() {
- return kms;
- }
- public void setKms(Integer kms) {
- this.kms = kms;
- }
- public Integer getDias() {
- return dias;
- }
- public void setDias(Integer dias) {
- this.dias = dias;
- }
- public String getTipoVeiculo() {
- return tipoVeiculo;
- }
- public void setTipoVeiculo(String tipoVeiculo) {
- this.tipoVeiculo = tipoVeiculo.toUpperCase();
- }
- public Double calcular() {
- this.setValorKms();
- this.setValorDias();
- this.setValorAluguelKm();
- /*System.out.println("Valor km:" + this.getValorAluguelKm());
- System.out.println("Valor diarias:" + this.getValorDias());*/
- return this.getValorAluguelKm()+this.getValorDias();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement