-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathProduto.java
More file actions
57 lines (45 loc) · 1.16 KB
/
Produto.java
File metadata and controls
57 lines (45 loc) · 1.16 KB
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
public class Produto {
private int id;
private String nome;
private double preco;
public Produto() {
}
public Produto(int id, String nome, double preco) {
this.id = id;
this.nome = nome;
this.preco = preco;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public double getPreco() {
return preco;
}
public void setPreco(double preco) {
this.preco = preco;
}
@Override
public String toString() {
return "Produto{id=" + id + ", nome='" + nome + "', preco=R$ " + String.format("%.2f", preco) + "}";
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
Produto produto = (Produto) obj;
return id == produto.id;
}
@Override
public int hashCode() {
return Integer.hashCode(id);
}
}