-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForest.java
More file actions
55 lines (42 loc) · 1.09 KB
/
Forest.java
File metadata and controls
55 lines (42 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import java.util.*;
class Forest{
Random random = new Random();
private Bag bag;
private Pokemon wildPokemon;
private Ball ball;
private double mood;
private String name;
public Forest(){
}
public void pokemonFound(){
int pokemonRand = random.nextInt(3);
if(pokemonRand == 0)
wildPokemon = new Vulpix("Wild Vulpix");
else if(pokemonRand == 1)
wildPokemon = new Pikachu("Wild Pikachu");
else if(pokemonRand == 2)
wildPokemon = new Swinub("Wild Swinub");
mood = (random.nextInt(10)+1) /10.0;
System.out.println("Found " + wildPokemon.getName() + "!!");
}
public void catchPokemon(Bag bag){
mood += 0.05;
ball = new Ball(random.nextInt(3));
System.out.println(("Throw the ") + ball.getName());
if(catchSuccess()){
System.out.println("Gotcha! You got " + wildPokemon.getName());
bag.add(wildPokemon);
}
else
System.out.println("It break free!");
}
public boolean catchSuccess(){
if((this.mood * (ball.getOppotunity())) > 0.5)
return true;
else
return false;
}
public Pokemon gotPokemon(){
return wildPokemon;
}
}