Created
October 10, 2018 13:15
-
-
Save rodrigovilar/34d61712387f45dfbff96583b020daa9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public String extrato() { | |
| double valorTotal = 0.0; | |
| int pontosDeAlugadorFrequente = 0; | |
| String resultado = "Registro de Alugueis de " + getNome(); | |
| for (Aluguel cada : fitasAlugadas) { | |
| double valorCorrente = 0.0; | |
| switch (cada.getFita().getCodigoDePreço()) { | |
| case normal: | |
| valorCorrente += 2; | |
| if (cada.getDiasAlugada() > 2) | |
| valorCorrente += (cada.getDiasAlugada() - 2) * 1.5; | |
| break; | |
| case lancamento: | |
| valorCorrente += cada.getDiasAlugada() * 3; | |
| break; | |
| case infantil: | |
| valorCorrente += 1.5; | |
| if (cada.getDiasAlugada() > 3) | |
| valorCorrente += (cada.getDiasAlugada() - 3) * 1.5; | |
| break; | |
| } | |
| pontosDeAlugadorFrequente++; // trata de pontos de alugador frequente | |
| // adiciona bonus para aluguel de um lançamento por pelo menos 2 dias | |
| if (cada.getFita().getCodigoDePreço() == Fita.Tipo.lancamento | |
| && cada.getDiasAlugada() > 1) | |
| pontosDeAlugadorFrequente++; | |
| resultado += "\t" + cada.getFita().getTitulo() + "\t" + valorCorrente; | |
| valorTotal += valorCorrente; | |
| } | |
| resultado += "Valor total devido: " + valorTotal; | |
| return resultado + "Voce acumulou " + pontosDeAlugadorFrequente + | |
| " pontos de alugador frequente"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment