-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProduto.java
More file actions
69 lines (57 loc) · 1.63 KB
/
Copy pathProduto.java
File metadata and controls
69 lines (57 loc) · 1.63 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
58
59
60
61
62
63
64
65
66
67
68
public class Produto {
// ==========================
// ATRIBUTOS
// ==========================
private int id;
private String nome;
private double preco;
private int quantidade;
private Categoria categoria;
// ==========================
// CONSTRUTOR
// ==========================
public Produto(int id, String nome, double preco, int quantidade, Categoria categoria) {
this.id = id;
this.nome = nome;
this.preco = preco;
this.quantidade = quantidade;
this.categoria = categoria;
}
// ==========================
// GETTERS E SETTERS
// ==========================
public int getId() {
return this.id;
}
public String getNome() {
return this.nome;
}
public double getPreco() {
return this.preco;
}
public void setPreco(double preco) {
this.preco = preco;
}
public int getQuantidade() {
return this.quantidade;
}
public void setQuantidade(int quantidade) {
this.quantidade = quantidade;
}
public Categoria getCategoria() {
return this.categoria;
}
public void setCategoria(Categoria categoria) {
this.categoria = categoria;
}
// ==========================
// EXIBIÇÃO
// ==========================
@Override
public String toString() {
return "[" + this.id + "] " + this.nome
+ " | R$ " + String.format("%.2f", this.preco)
+ " | Qtd: " + this.quantidade
+ " | Categoria: " + this.categoria.getNome();
}
}