-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBolsa.java
More file actions
39 lines (31 loc) · 1.09 KB
/
Bolsa.java
File metadata and controls
39 lines (31 loc) · 1.09 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
package PokeJava;
import java.util.ArrayList;
import java.util.List;
public class Bolsa {
private List<Item> itens;
public Bolsa() {
itens = new ArrayList<>();
itens.add(new PocaoSimples());
itens.add(new PocaoQueimadura());
itens.add(new PocaoConfusao());
itens.add(new PocaoParalisia());
}
public void usarItem(int indice, Pokemon pokemon){
if(indice >= 0 && indice < itens.size() ){
itens.get(indice).usar(pokemon);
itens.remove(indice);
}else{
System.out.println("ITEM INVÁLIDO.");
}
}
public void listarItens(){
System.out.println("______________________________________________________________________");
System.out.println(" ITENS DISPONÍVEIS:");
for (int i = 0; i < itens.size(); i++) {
if(itens.isEmpty()){
System.out.println(" BOLSA VAZIA!");
}
System.out.println("ITEM "+ i + " - "+ itens.get(i).getNome());
}
}
}