-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTesteProduto.java
More file actions
32 lines (26 loc) · 1.39 KB
/
TesteProduto.java
File metadata and controls
32 lines (26 loc) · 1.39 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
package estoquepapelaria;
public class TesteProduto {
public static void main(String[] args) {
System.out.println("=== Teste 1: Criacao valida ===");
Produto caneta = new Produto("Caneta Azul", 2.50, 0.50, 100);
caneta.exibirInformacoes();
System.out.println("\n=== Teste 2: Adicao ao estoque ===");
int novoEstoque = caneta.adicionarEstoque(50);
System.out.println("Novo estoque: " + novoEstoque);
System.out.println("\n=== Teste 3: Remocao bem-sucedida ===");
novoEstoque = caneta.removerEstoque(30);
System.out.println("Novo estoque apos remocao: " + novoEstoque);
System.out.println("\n=== Teste 4: Tentativa de remover mais do que disponivel ===");
novoEstoque = caneta.removerEstoque(500);
if (novoEstoque == -1) {
System.out.println("Falha na remocao: estoque insuficiente.");
}
System.out.println("\n=== Teste 5: Remocao com quantidade negativa ===");
caneta.removerEstoque(-5);
System.out.println("\n=== Teste 6: Criacao com dados invalidos ===");
new Produto("", 5.0, 0.0, 10); // Nome inválido
new Produto("Lapis", -1.0, 0.0, 10); // Preço inválido
new Produto("Borracha", 2.0, 5.0, 10); // Desconto maior que preço
new Produto("Regua", 3.0, 1.0, -10); // Estoque negativo
}
}