-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from Sergiorezende22/develop
Etapa 4 - Desenvolvimento v4.0
- Loading branch information
Showing
46 changed files
with
2,425 additions
and
234 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
rootProject.name = 'Quicksell' | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,93 @@ | ||
package br.ufrrj.quicksell; | ||
|
||
import br.ufrrj.quicksell.views.HomeFrame; | ||
import br.ufrrj.quicksell.controlers.Sistema; | ||
import br.ufrrj.quicksell.entities.Corretor; | ||
import br.ufrrj.quicksell.entities.Imobiliaria; | ||
import br.ufrrj.quicksell.entities.Imovel; | ||
import br.ufrrj.quicksell.entities.Usuario; | ||
import br.ufrrj.quicksell.utils.Endereco; | ||
import br.ufrrj.quicksell.utils.TipoDeImovel; | ||
import br.ufrrj.quicksell.views.LoginFrame; | ||
import com.formdev.flatlaf.intellijthemes.FlatCyanLightIJTheme; | ||
import com.formdev.flatlaf.intellijthemes.FlatDraculaIJTheme; | ||
import com.formdev.flatlaf.intellijthemes.FlatOneDarkIJTheme; | ||
|
||
import javax.swing.*; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class Main { | ||
// loginFrameWidth = 400; | ||
// loginFrameHeight = 500; | ||
public static void main(String[] args) { | ||
FlatCyanLightIJTheme.setup(); | ||
|
||
new HomeFrame(1024, 720); | ||
new LoginFrame(400, 500); | ||
Endereco endereco = new Endereco("Soares", "26379060", "Vila S\u00E3o Jo\u00E3o", "40", "Queimados", "Rio de Janeiro", " "); | ||
Endereco endereco1 = new Endereco("Irene", "26276370", "Comendador Soares", "000", "Nova Igua\u00E7u", "Rio de Janeiro", " "); | ||
Endereco endereco2 = new Endereco("Meriti", "21211007", "Vila da Penha", "777", "Rio de Janeiro", "Rio de Janeiro", " "); | ||
Endereco endereco3 = new Endereco("Volta", "21220000", "Vila da Penha", "123", "Rio de Janeiro", "Rio de Janeiro", " "); | ||
Endereco endereco4 = new Endereco("das Am\u00E9ricas", "22640602", "Cordovil", "10", "Rio de Janeiro", "Rio de Janeiro", " "); | ||
Endereco endereco5 = new Endereco("Wesley Advicunha de Souza", "26292492", "Campo Alegre", "27", "Nova Igua\u00E7u", "Rio de Janeiro", " "); | ||
|
||
List<Imovel> listaNicolas = new ArrayList<Imovel>(); | ||
List<Imovel> listaSergio = new ArrayList<Imovel>(); | ||
List<Imovel> listaImobiliaria = new ArrayList<Imovel>(); | ||
List<Imovel> listaRespCorretor = new ArrayList<Imovel>(); | ||
List<Imovel> listaRespCorretor1 = new ArrayList<Imovel>(); | ||
List<Corretor> corretores = new ArrayList<Corretor>(); | ||
|
||
Usuario nicolas = new Usuario("Nicolas Magalh\u00E3es", "123456789", "26656666", endereco1, "[email protected]", "123", listaNicolas); | ||
Usuario sergio = new Usuario("S\u00E9rgio Felipe", "027456712", "90909090", endereco, "[email protected]", "123", listaSergio); | ||
Corretor corretor = new Corretor("Eduardo Vieira", "867491273", "12345678", endereco2,"[email protected]","123", listaRespCorretor); | ||
Corretor corretor1 = new Corretor("Bruno Almeida", "456172367", "54612678", endereco2,"[email protected]","123", listaRespCorretor1); | ||
|
||
corretores.add(corretor); | ||
corretores.add(corretor1); | ||
|
||
Imobiliaria imobiliaria = new Imobiliaria("Imor Tal", "[email protected]", listaImobiliaria, corretores); | ||
|
||
Imovel imovelSergio = new Imovel(950000, 200, "Casa totalmente mobiliada, com 4 quartos(2 su\u00EDtes), 1 banheiro, 1 cozinha e 2 salas de estar. \u00C1rea de lazer com piscina e churrasqueira.", | ||
endereco, sergio, "Casa_Braba.jpg", TipoDeImovel.RESIDENCIAL); | ||
|
||
Imovel imovelNicolas = new Imovel(180000, 100, "Apenas o terreno, \u00E1rea nobre de Nova de Igua\u00E7u.", | ||
endereco1, nicolas, "Terreno_Baldio.jpg", TipoDeImovel.RESIDENCIAL); | ||
|
||
Imovel imovelImo1 = new Imovel(300000, 80, "Casa pronta, sem mobilia, com 2 quartos, 1 cozinha e 1 banheiro.", | ||
endereco2, imobiliaria, "Casa_Simples.jpg", TipoDeImovel.RESIDENCIAL); | ||
|
||
Imovel imovelImo2 = new Imovel(120000, 45, "Quitinete na grande cidade do Rio de Janeiro.", | ||
endereco3, imobiliaria, "Quitinete.jpg", TipoDeImovel.RESIDENCIAL); | ||
|
||
Imovel imovelImo3 = new Imovel(400000, 70, "Apartamento em condom\u00EDnio fechado, excelente para crian\u00E7as.", | ||
endereco4, imobiliaria, "Apartamento.jpg", TipoDeImovel.RESIDENCIAL); | ||
|
||
Imovel imovelImo4 = new Imovel(100000, 200, "Uma \u00F3tima oportunidade, local aconchegante, com 3 quarto, 2 banheiros, 1 por\u00E3o bem escuro e totalmente seguro.", | ||
endereco5, imobiliaria, "Casa_Segura.jpg", TipoDeImovel.RESIDENCIAL); | ||
|
||
listaRespCorretor.add(imovelImo1); | ||
listaRespCorretor.add(imovelImo4); | ||
listaRespCorretor1.add(imovelImo2); | ||
listaRespCorretor1.add(imovelImo3); | ||
|
||
|
||
listaNicolas.add(imovelNicolas); | ||
listaSergio.add(imovelSergio); | ||
|
||
listaImobiliaria.add(imovelImo1); | ||
listaImobiliaria.add(imovelImo2); | ||
listaImobiliaria.add(imovelImo3); | ||
listaImobiliaria.add(imovelImo4); | ||
|
||
Sistema.pegarInstancia().addImovel(imovelImo1); | ||
Sistema.pegarInstancia().addImovel(imovelImo2); | ||
Sistema.pegarInstancia().addImovel(imovelImo3); | ||
Sistema.pegarInstancia().addImovel(imovelImo4); | ||
Sistema.pegarInstancia().addImovel(imovelNicolas); | ||
Sistema.pegarInstancia().addImovel(imovelSergio); | ||
Sistema.setImobiliaria(imobiliaria); | ||
Sistema.pegarInstancia().addUsuario(sergio); | ||
Sistema.pegarInstancia().addUsuario(nicolas); | ||
Sistema.pegarInstancia().addUsuario(corretor); | ||
Sistema.pegarInstancia().addUsuario(corretor1); | ||
|
||
|
||
new LoginFrame(); | ||
} | ||
} |
141 changes: 141 additions & 0 deletions
141
Código/src/main/java/br/ufrrj/quicksell/controlers/Sistema.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
package br.ufrrj.quicksell.controlers; | ||
|
||
|
||
import br.ufrrj.quicksell.entities.*; | ||
import br.ufrrj.quicksell.utils.Data; | ||
import br.ufrrj.quicksell.views.HomeFrame; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class Sistema { | ||
private static Sistema instancia; | ||
private static List<Usuario> listaDeUsuarios; | ||
private Usuario usuarioAtual; | ||
|
||
private static List<Imovel> listaDeImoveis; | ||
private static List<Imovel> listaDeImoveisFiltrada; | ||
private Imovel imovelAtual; | ||
|
||
private static Imobiliaria imobiliaria; | ||
|
||
private Data data; | ||
|
||
private Sistema() { } | ||
|
||
public static synchronized Sistema pegarInstancia() { | ||
if(instancia == null){ | ||
instancia = new Sistema(); | ||
listaDeUsuarios = new ArrayList<Usuario>(); | ||
listaDeImoveis = new ArrayList<Imovel>(); | ||
} | ||
|
||
return instancia; | ||
} | ||
|
||
public boolean fazerLogin(String email, String senha) { | ||
Usuario usuario = filtrarUsuarioPorEmail(email); | ||
if(usuario == null) | ||
System.out.println("Não existe usuario com esse email"); | ||
else | ||
{ | ||
if(usuario.getSenha().equals(senha)) { | ||
usuarioAtual = usuario; | ||
criarListaFiltradaParaUsuario(); | ||
new HomeFrame(); | ||
return true; | ||
} | ||
else | ||
System.out.println("Senha incorreta"); | ||
|
||
} | ||
return false; | ||
} | ||
|
||
public Usuario filtrarUsuarioPorEmail (String email) { | ||
for (Usuario usuario : listaDeUsuarios ) { | ||
if(usuario.getEmail().equals(email)) | ||
return usuario; | ||
} | ||
return null; | ||
} | ||
|
||
public void selecionarImovel(Imovel imovel) { | ||
this.imovelAtual = imovel; | ||
} | ||
|
||
public void deslogar() { | ||
usuarioAtual = null; | ||
} | ||
|
||
public void criarListaFiltradaParaUsuario() { | ||
listaDeImoveisFiltrada = new ArrayList<Imovel>(); | ||
|
||
if(usuarioAtual instanceof Corretor){ | ||
listaDeImoveisFiltrada.addAll(listaDeImoveis); | ||
return; | ||
} | ||
|
||
for(Imovel imovel : listaDeImoveis) | ||
if(imovel.getProprietario() instanceof Imobiliaria) { | ||
listaDeImoveisFiltrada.add(imovel); | ||
} | ||
} | ||
|
||
public void fazerProposta(float valor, String descricao) { | ||
Proposta proposta = usuarioAtual.criarProposta(imovelAtual, valor, descricao, data); | ||
imovelAtual.addProposta(proposta); | ||
} | ||
|
||
public static Imobiliaria getImobiliaria() { | ||
return imobiliaria; | ||
} | ||
|
||
public static void setImobiliaria(Imobiliaria imobiliaria) { | ||
Sistema.imobiliaria = imobiliaria; | ||
} | ||
|
||
public Usuario getUsuarioAtual() { | ||
return usuarioAtual; | ||
} | ||
|
||
public Imovel getImovelAtual() { | ||
return imovelAtual; | ||
} | ||
|
||
public static List<Imovel> getListaDeImoveisFiltrada() { | ||
return listaDeImoveisFiltrada; | ||
} | ||
|
||
public void addUsuario (Usuario usuario) { | ||
listaDeUsuarios.add(usuario); | ||
} | ||
|
||
public void addImovel (Imovel imovel) { | ||
listaDeImoveis.add(imovel); | ||
} | ||
|
||
public void filtrarPorPreco(float menorQue, float maiorQue) { | ||
listaDeImoveisFiltrada = listaDeImoveisFiltrada.stream().filter(imovel -> { | ||
return imovel.getValor() <= menorQue && imovel.getValor() >= maiorQue; | ||
}).collect(Collectors.toList()); | ||
for (Imovel imovel : listaDeImoveisFiltrada) | ||
{ | ||
System.out.println(imovel.getValor()); | ||
} | ||
} | ||
|
||
public void filtrarPorBairro(String bairro) { | ||
listaDeImoveisFiltrada = listaDeImoveisFiltrada.stream().filter(imovel -> { | ||
return imovel.getEndereco().getBairro().equals(bairro); | ||
}).collect(Collectors.toList()); | ||
} | ||
|
||
public void filtrarPorTipo(String tipo) { | ||
listaDeImoveisFiltrada = listaDeImoveisFiltrada.stream().filter(imovel -> { | ||
return imovel.getTipoDeImovelString().equals(tipo); | ||
}).collect(Collectors.toList()); | ||
} | ||
} | ||
|
37 changes: 37 additions & 0 deletions
37
Código/src/main/java/br/ufrrj/quicksell/entities/Corretor.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package br.ufrrj.quicksell.entities; | ||
|
||
import br.ufrrj.quicksell.utils.Endereco; | ||
|
||
import java.util.List; | ||
|
||
public class Corretor extends Usuario { | ||
private String creci; | ||
private Imobiliaria imobiliaria; | ||
private List<Imovel> imoveisGerenciados; | ||
|
||
|
||
|
||
private void addImovel(Imovel imovel){} | ||
|
||
public Corretor(String nome, String cpf, String telefone, Endereco endereco, String email, String senha, List<Imovel> imoveisGerenciados) { | ||
super(nome, cpf, telefone, endereco, email, senha); | ||
this.imoveisGerenciados = imoveisGerenciados; | ||
} | ||
|
||
public Corretor(String nome, String cpf, String telefone, Endereco endereco, String email, String senha, List<Imovel> imoveis, List<Imovel> imoveisGerenciados) { | ||
super(nome, cpf, telefone, endereco, email, senha, imoveis); | ||
this.imoveisGerenciados = imoveisGerenciados; | ||
} | ||
|
||
public List<Imovel> getImoveisGerenciados() { | ||
return imoveisGerenciados; | ||
} | ||
|
||
public boolean checarResponsabilidade (Imovel imovel) { | ||
for(Imovel imovelIte : imoveisGerenciados) { | ||
if(imovelIte.equals(imovel)) | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
Código/src/main/java/br/ufrrj/quicksell/entities/Imobiliaria.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package br.ufrrj.quicksell.entities; | ||
|
||
import java.util.List; | ||
|
||
public class Imobiliaria extends Proprietario { | ||
private String nome; | ||
private String cnpj; | ||
private String email; | ||
private List<Corretor> corretores; | ||
|
||
public Imobiliaria(String nome, String email, List<Imovel> imoveis, List<Corretor> corretores) { | ||
this.imoveis = imoveis; | ||
this.nome = nome; | ||
this.email = email; | ||
this.corretores = corretores; | ||
} | ||
|
||
public Usuario pegarResponsavel(Imovel imovelAtual) { | ||
for(Corretor corretor : corretores) { | ||
if(corretor.checarResponsabilidade(imovelAtual)) | ||
return (Usuario) corretor; | ||
} | ||
return null; | ||
} | ||
|
||
|
||
public String getNome() { | ||
return "Imobili\u00E1ria " + nome; | ||
} | ||
|
||
|
||
public String getEmail(){ | ||
return email; | ||
} | ||
|
||
} |
Oops, something went wrong.