-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPokePartner.java
More file actions
165 lines (128 loc) · 5.06 KB
/
PokePartner.java
File metadata and controls
165 lines (128 loc) · 5.06 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import java.util.*;
public class PokePartner {
private ArrayList<Ball> ball2;
private ArrayList<Ball> balls;
private ArrayList<PokemonTrainer> trainer;
public PokePartner(){
balls = new ArrayList<Ball>();
trainer = new ArrayList<PokemonTrainer>();
ball2 = new ArrayList<Ball>();
}
public void select(){
Ptrainer s = new Ptrainer("RED",5,5000);
trainer.add(s);
s.addBall();
ball2 = s.getBall();
}
public ArrayList<PokemonTrainer> act(){
select();
return trainer;
}
public void addBall(ArrayList<Ball> ball){
PokeBall pokeball = new PokeBall("Pokeball");
Quickball quickball = new Quickball("Quickball");
Timerball timerball = new Timerball("Timerball");
Ultraball ultraball = new Ultraball("Ultraball");
Masterball masterball = new Masterball("Masterball");
for(Ball b : ball){
if(b.getName() == "Pokeball"){
balls.add(pokeball);
}
else if(b.getName() == "Quickball"){
balls.add(quickball);
}
else if(b.getName() == "Timerball"){
balls.add(timerball);
}
else if(b.getName() == "Ultraball"){
balls.add(ultraball);
}
else if(b.getName() == "Masterball"){
balls.add(masterball);
}
}
for(int i = 0 ; i < balls.size()-1 ; ++i){
if(balls.get(i).getName() == balls.get(i+1).getName()){
balls.remove(i+1);
check(pokeball, quickball, timerball, ultraball, masterball, i);
}
}
for(int i = 0 ; i < balls.size()-2 ; ++i){
if(balls.get(i).getName() == balls.get(i+2).getName()){
balls.remove(i+2);
check(pokeball, quickball, timerball, ultraball, masterball, i);
}
}
for(int i = 0 ; i < balls.size()-2 ; ++i){
if(balls.get(i).getName() == balls.get(i+2).getName()){
balls.remove(i+2);
check(pokeball, quickball, timerball, ultraball, masterball, i);
}
}
for(int i = 0 ; i < balls.size()-3; ++i){
if(balls.get(i).getName() == balls.get(i+3).getName()){
balls.remove(i+3);
check(pokeball, quickball, timerball, ultraball, masterball, i);
}
}
for(int i = 0 ; i < balls.size()-4 ; ++i){
if(balls.get(0).getName() == balls.get(4).getName()){
balls.remove(4);
check(pokeball, quickball, timerball, ultraball, masterball, 0);
}
// if(balls.get(1).getName() == balls.get(4).getName()){
// balls.remove(4);
// check(pokeball, quickball, timerball, ultraball, masterball, 1);
// }
}
for(int i = 0 ; i < balls.size()-1 ; ++i){
if(balls.get(i) == balls.get(i+1)){
balls.remove(i+1);
check(pokeball, quickball, timerball, ultraball, masterball, i);
}
}
}
public ArrayList<Ball> TrainerBall() {
balls.removeAll(balls);
addBall(ball2);
return balls;
}
public void check(PokeBall pokeball,Quickball quickball,Timerball timerball, Ultraball ultraball ,Masterball masterball,int i){
if(balls.get(i).getName() == "Pokeball"){
int num = pokeball.getNumber() + 1 ;
pokeball.setNumber(num);
}
else if(balls.get(i).getName() == "Quickball"){
int num = quickball.getNumber() + 1 ;
quickball.setNumber(num);
}
else if(balls.get(i).getName() == "Timerball"){
int num = timerball.getNumber() + 1 ;
timerball.setNumber(num);
}
else if(balls.get(i).getName() == "Ultraball"){
int num = ultraball.getNumber() + 1 ;
ultraball.setNumber(num);
}
else if(balls.get(i).getName() == "Masterball"){
int num = masterball.getNumber() + 1 ;
masterball.setNumber(num);
}
}
public void deleteBall(Ball b){
System.out.println(b);
int ballNum = b.getNumber()-1;
b.setNumber(ballNum);
System.out.println(b);
if(ballNum == 0){
b.setNumber(0);
}
}
public void toString(ArrayList<PokemonTrainer> trainers){
int number = 0;
for(PokemonTrainer t : trainers){
System.out.println("" + number + " " + t );
number++ ;
}
}
}