reaproveitamento-poo-java

commit 13f07b090fea24fbc67f39e6889ebda4284699f3

Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>

all: calculate ITBI for locations

 src/org/porcellis/Main.java | 3 +++
 src/org/porcellis/controllers/ImovelController.java | 6 ++++++
 src/org/porcellis/models/Apartamento.java | 7 +++++++
 src/org/porcellis/models/Casa.java | 7 +++++++
 src/org/porcellis/views/ImovelView.java | 2 +-


diff --git a/src/org/porcellis/Main.java b/src/org/porcellis/Main.java
index c96180a2c91ef1566fe2c06603941a01a8a41186..f39cc91a8d99fb99ce697f548cb0c759587979df 100644
--- a/src/org/porcellis/Main.java
+++ b/src/org/porcellis/Main.java
@@ -106,6 +106,9 @@
 		imovelController.listarImoveis();
 		imobiliariaController.listarImobiliarias();
 
+		System.out.println("\n\tListar ITBIs dos locais:\n");
+		imovelController.calcularITBI();
+
 		System.out.println("\nXau!");
 	}
 }




diff --git a/src/org/porcellis/controllers/ImovelController.java b/src/org/porcellis/controllers/ImovelController.java
index 1ef9c7e623a334a135fd82bac40dcf66243c1592..af5ff632ae7ab9a2d636b7153d6679f468c04e9d 100644
--- a/src/org/porcellis/controllers/ImovelController.java
+++ b/src/org/porcellis/controllers/ImovelController.java
@@ -19,6 +19,12 @@ 	public void adicionarImovel(Imovel imovel) {
 		imoveis.add(imovel);
 	}
 
+	public void calcularITBI() {
+		for (Imovel imovel : imoveis) {
+			imovelView.mostrarITBI(imovel);
+		}
+	}
+
 	public void listarImoveis() {
 		for (Imovel imovel : imoveis) {
 			imovelView.mostrarDetalhesImovel(imovel);




diff --git a/src/org/porcellis/models/Apartamento.java b/src/org/porcellis/models/Apartamento.java
index 6de51842e0cfeca04765b8a83af01b86eb1b1fba..297639ec1e550ed92a72a72d6fca74300f6c5dc8 100644
--- a/src/org/porcellis/models/Apartamento.java
+++ b/src/org/porcellis/models/Apartamento.java
@@ -1,5 +1,7 @@
 package org.porcellis.models;
 
+import org.porcellis.models.utils.Taxas;
+
 public class Apartamento extends Imovel {
 	private String nomeCondominio;
 
@@ -8,6 +10,11 @@ 			precoVenda, String nomeCondominio) {
 		super(endereco, areaUtil, precoCotacao, precoVenda);
 
 		this.nomeCondominio = nomeCondominio;
+	}
+
+	@Override
+	public double getITBI() {
+		return getPrecoCotacao() * Taxas.ITBI_APARTAMENTO;
 	}
 
 	public String getNomeCondominio() {




diff --git a/src/org/porcellis/models/Casa.java b/src/org/porcellis/models/Casa.java
index c340cbd141e3080a4ee30b21b174132878b02acf..525a6e894ec792cc787ce70d35ce4cb9d4710475 100644
--- a/src/org/porcellis/models/Casa.java
+++ b/src/org/porcellis/models/Casa.java
@@ -1,5 +1,7 @@
 package org.porcellis.models;
 
+import org.porcellis.models.utils.Taxas;
+
 public class Casa extends Imovel {
 	private double tamanhoDoTerreno;
 
@@ -8,6 +10,11 @@ 			precoVenda, double tamanhoDoTerreno) {
 		super(endereco, areaUtil, precoCotacao, precoVenda);
 
 		this.tamanhoDoTerreno = tamanhoDoTerreno;
+	}
+
+	@Override
+	public double getITBI() {
+		return getPrecoCotacao() * Taxas.ITBI_CASA;
 	}
 
 	public double getTamanhoDoTerreno() {




diff --git a/src/org/porcellis/views/ImovelView.java b/src/org/porcellis/views/ImovelView.java
index 96ebfbdd642c2f09afe8e1647006ac2d0c4c1faa..e89caf111f854370c25aed6951ca44578a5074bd 100644
--- a/src/org/porcellis/views/ImovelView.java
+++ b/src/org/porcellis/views/ImovelView.java
@@ -8,7 +8,7 @@ 		System.out.println(imovel.toString());
 		System.out.println("\n");
 	}
 
-	public void mostrarITBI(Imovel imovel, double itbi) {
+	public void mostrarITBI(Imovel imovel) {
 		System.out.println(
 				String.format(
 					"O ITBI do imóvel %s é: %.2f%n",