Advertisement
hercioneto

Classe FichaAluguel

Nov 27th, 2023
850
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.41 KB | None | 0 0
  1. /* Criar a classe FichaAluguel colar abaixo do packpage */
  2. /**
  3.  *
  4.  * @author Professor Hercio Neto
  5.  */
  6. public class FichaAluguel {
  7.     private Double valorDiaria;
  8.     private Double valorAluguelKm;
  9.     private Double valorDias;
  10.     private Double valorKms;
  11.     private Integer kms;
  12.     private Integer dias;
  13.     private String tipoVeiculo;
  14.    
  15.  
  16.     public Double getValorDiaria() {
  17.         return valorDiaria;
  18.     }
  19.  
  20.     public void setValorDiaria(Double valorDiaria) {
  21.         this.valorDiaria = valorDiaria;
  22.     }
  23.  
  24.     public Double getValorAluguelKm() {
  25.         return valorAluguelKm;
  26.     }
  27.  
  28.     public void setValorAluguelKm() {
  29.         this.valorAluguelKm = this.getValorKms()*this.getKms();
  30.     }
  31.  
  32.     public Double getValorDias() {
  33.         return valorDias;
  34.     }
  35.  
  36.     public void setValorDias() {
  37.         Double valorDias = this.valorDiaria*this.getDias();
  38.         this.valorDias = valorDias;
  39.     }
  40.  
  41.     public Double getValorKms() {
  42.         return valorKms;
  43.     }
  44.  
  45.     public void setValorKms() {
  46.         Double valorKm=0d;
  47.         if ("POPULAR".equals(this.getTipoVeiculo())) {
  48.            
  49.             this.setValorDiaria(90.00d);
  50.             if (this.getKms() >=100) {
  51.             valorKm = 0.20d; } else {
  52.                valorKm = 0.10d;
  53.             }
  54.         }
  55.         if ("LUXO".equals(this.getTipoVeiculo())) {
  56.             this.setValorDiaria(150.00d);            
  57.             if (this.getKms() >=200) {
  58.             valorKm = 0.30d; } else {
  59.                valorKm = 0.25d;
  60.             }
  61.         }
  62.         this.valorKms = valorKm;
  63.     }
  64.  
  65.     public Integer getKms() {
  66.         return kms;
  67.     }
  68.  
  69.     public void setKms(Integer kms) {
  70.         this.kms = kms;
  71.     }
  72.  
  73.     public Integer getDias() {
  74.         return dias;
  75.     }
  76.  
  77.     public void setDias(Integer dias) {
  78.         this.dias = dias;
  79.     }
  80.  
  81.     public String getTipoVeiculo() {
  82.         return tipoVeiculo;
  83.     }
  84.  
  85.     public void setTipoVeiculo(String tipoVeiculo) {
  86.         this.tipoVeiculo = tipoVeiculo.toUpperCase();
  87.     }
  88.    
  89.     public Double calcular() {      
  90.         this.setValorKms();
  91.         this.setValorDias();
  92.         this.setValorAluguelKm();
  93.         /*System.out.println("Valor km:" + this.getValorAluguelKm());
  94.         System.out.println("Valor diarias:" + this.getValorDias());*/          
  95.         return this.getValorAluguelKm()+this.getValorDias();
  96.        
  97.     }
  98.    
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement