reaproveitamento-poo-java

commit ee8ac8f735416ddb8c9ca13177dfb764cc97789d

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

controllers, views: introduce very basic controllers and views for imoveis and imobiliarias

 src/org/porcellis/controllers/ImobiliariaController.java | 27 ++++++++++
 src/org/porcellis/controllers/ImovelController.java | 19 +++++-
 src/org/porcellis/views/ImobiliariaView.java | 10 +++
 src/org/porcellis/views/ImovelView.java | 7 ++


diff --git a/src/org/porcellis/controllers/ImobiliariaController.java b/src/org/porcellis/controllers/ImobiliariaController.java
new file mode 100644
index 0000000000000000000000000000000000000000..eadb121dfa0d7fb518c4f9469f847831ad56d621
--- /dev/null
+++ b/src/org/porcellis/controllers/ImobiliariaController.java
@@ -0,0 +1,27 @@
+package org.porcellis.controllers;
+
+import org.porcellis.models.Imobiliaria;
+import org.porcellis.views.ImobiliariaView;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ImobiliariaController {
+	private ImobiliariaView imobiliariaView;
+	private List<Imobiliaria> imobiliarias;
+
+	public ImobiliariaController(ImobiliariaView imobiliariaView) {
+		this.imobiliarias = new ArrayList<Imobiliaria>();
+		this.imobiliariaView = imobiliariaView;
+	}
+
+	public void adicionarImobiliaria(Imobiliaria imobiliaria) {
+		imobiliarias.add(imobiliaria);
+	}
+
+	public void listarImobiliarias() {
+		for (Imobiliaria imobiliaria : imobiliarias) {
+			imobiliariaView.mostrarDetalhesImobiliaria(imobiliaria);
+		}
+	}
+}




diff --git a/src/org/porcellis/controllers/ImovelController.java b/src/org/porcellis/controllers/ImovelController.java
index 28ab51c5296964dfa2e27936edb750afaa1ec7f5..1ef9c7e623a334a135fd82bac40dcf66243c1592 100644
--- a/src/org/porcellis/controllers/ImovelController.java
+++ b/src/org/porcellis/controllers/ImovelController.java
@@ -3,16 +3,25 @@
 import org.porcellis.models.Imovel;
 import org.porcellis.views.ImovelView;
 
+import java.util.ArrayList;
+import java.util.List;
+
 public class ImovelController {
-	private Imovel imovel;
 	private ImovelView imovelView;
+	private List<Imovel> imoveis;
 
-	public ImovelController(Imovel imovel, ImovelView imovelView) {
-		this.imovel = imovel;
+	public ImovelController(ImovelView imovelView) {
+		this.imoveis = new ArrayList<Imovel>();
 		this.imovelView = imovelView;
 	}
 
-	public void mostrarDetalhesImovel() {
-		imovelView.mostrarDetalhesImovel(imovel);
+	public void adicionarImovel(Imovel imovel) {
+		imoveis.add(imovel);
+	}
+
+	public void listarImoveis() {
+		for (Imovel imovel : imoveis) {
+			imovelView.mostrarDetalhesImovel(imovel);
+		}
 	}
 }




diff --git a/src/org/porcellis/views/ImobiliariaView.java b/src/org/porcellis/views/ImobiliariaView.java
new file mode 100644
index 0000000000000000000000000000000000000000..21f4aeb207e9b5a5401622a2f10c3f7f48eb0fea
--- /dev/null
+++ b/src/org/porcellis/views/ImobiliariaView.java
@@ -0,0 +1,10 @@
+package org.porcellis.views;
+
+import org.porcellis.models.Imobiliaria;
+
+public class ImobiliariaView {
+	public void mostrarDetalhesImobiliaria(Imobiliaria imobiliaria) {
+		System.out.println(imobiliaria);
+	}
+}
+




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