forked from EduGiehl/Banco-Imobiliario
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCasa.java
83 lines (56 loc) · 1.56 KB
/
Casa.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
import java.awt.image.BufferedImage;
public class Casa {
private int id;
private int x, y; // Coordenadas para posicionar a casa no painel
private int qtd;
private BufferedImage[] casas; // Torne o atributo não estático (para instâncias individuais)
public Casa(int id, int x, int y) {
this.id = id;
this.x = x;
this.y = y;
this.qtd = 0; // Inicializa a quantidade
casas = new BufferedImage[4];
for (int i = 0; i < 4; i++) {
try {
casas[i] = ImageIO.read(new File("./imagens/dados/dado_" + (i + 1) + ".png"));
} catch (IOException e) {
e.printStackTrace();
casas[i] = null; // Define como nulo se a imagem não for carregada
}
}
}
public BufferedImage getImagem(int index) {
if (index >= 0 && index < casas.length) {
return casas[index];
}
return null; // Retorna nulo se o índice for inválido
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public int getQtd() {
return this.qtd ;
}
public void addQtd() {
this.qtd = this.qtd+1;
}
// Getters e setters omitidos por brevidade
}