-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasseProduto.java
More file actions
42 lines (34 loc) · 1.02 KB
/
Copy pathclasseProduto.java
File metadata and controls
42 lines (34 loc) · 1.02 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
import java.util.Scanner;
public class Produto {
private final String NOME;
private final double PRECO;
private int estoque;
public Produto() {
Scanner scanner = new Scanner(System.in);
System.out.println("Insira dados do produto: ");
System.out.print("Nome: ");
this.NOME = scanner.nextLine();
System.out.print("preço: ");
this.PRECO = scanner.nextDouble();
System.out.print("estoque: ");
this.estoque = scanner.nextInt();
}
public double totalNoEstoque() {
return PRECO * estoque;
}
public void addProdutos(int estoque) {
this.estoque += estoque;
}
public void removerProduto(int estoque) {
this.estoque -= estoque;
}
public String toString() {
return NOME
+ ", $ "
+ String.format("%.2f", PRECO)
+ ", "
+ estoque
+ " unidades, total: $ "
+ String.format("%.2f", totalNoEstoque());
}
}