-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarket.java
More file actions
256 lines (175 loc) · 7.42 KB
/
Market.java
File metadata and controls
256 lines (175 loc) · 7.42 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.*;
public class Market extends JFrame {
private static final long serialVersionUID = 1L;
private ArrayList<Ball> balls;
public Market(Citrus ci, Shuca s, Tamato t, ArrayList<Ball> ball2) {
super("Pokemon Market");
balls = new ArrayList<Ball>();
//System.out.println(ball2);
Container c = getContentPane();
Font myFont = null;
try{
myFont = Font.createFont( Font.TRUETYPE_FONT, new FileInputStream ( "font3/LmsPokedex-XEja.ttf" ) );
}catch ( FontFormatException error ){
}catch ( FileNotFoundException error ){
}catch ( IOException error ){
}
PokeBall pokeball = new PokeBall("Pokeball");
Quickball quickball = new Quickball("Quickball");
Ultraball ultraball = new Ultraball("Ultraball");
pokeball.setNumber(0);
quickball.setNumber(0);
ultraball.setNumber(0);
balls.add(pokeball);
balls.add(ultraball);
balls.add(quickball);
for (Ball ball : ball2) {
if (ball.getName() == "Pokeball") {
int num = ball.getNumber();
pokeball.setNumber(num);
//System.out.println(balls);
} else if (ball.getName() == "Quickball") {
int num = ball.getNumber();
quickball.setNumber(num);
} else if (ball.getName() == "Ultraball") {
int num = ball.getNumber();
ultraball.setNumber(num);
//System.out.println(balls);
}
}
//System.out.println(balls);
JPanel pk1 = new JPanel();
pk1.setBackground(new Color(153, 255, 102));
JLabel k1 = new JLabel("Welcome to BerriesMarket ", JLabel.CENTER);
k1.setFont(myFont.deriveFont(Font.PLAIN,30));
k1.setForeground(Color.BLACK);
pk1.add(k1);
JPanel panel1 = new JPanel ( );
panel1.setLayout ( new BorderLayout ( ) );
JButton b1 = new JButton("Sitrus Berry");
b1.addActionListener(new ActionListener(){
//anonymous class
public void actionPerformed(ActionEvent e) {
addBerry(ci);
}
});
JButton b2 = new JButton("Shuca Berry");
b2.addActionListener(new ActionListener(){
//anonymous class
public void actionPerformed(ActionEvent e) {
addBerry(s);
}
});
JButton b3 = new JButton("Tamato Berry");
b3.addActionListener(new ActionListener(){
//anonymous class
public void actionPerformed(ActionEvent e) {
addBerry(t);
}
});
JButton d1 = new JButton("CLOSE");
d1.addActionListener(new ActionListener(){
//anonymous class
public void actionPerformed(ActionEvent e) {
System.out.println("Have : "+ci.getNum()+" Sitrus Berry "+ s.getNum()+ " Shuca Berry "+ t.getNum()+ " Tamato Berry ");
setVisible(false);
}
});
JLabel j1 = new JLabel(new ImageIcon("img/market.gif"));
JPanel p3 = new JPanel ( );
p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS));
b1.add(Box.createRigidArea(new Dimension(150, 94)));
b2.add(Box.createRigidArea(new Dimension(150, 94)));
b3.add(Box.createRigidArea(new Dimension(150, 118)));
p3.add(b1);
p3.add(b2);
p3.add(b3);
panel1.add ( pk1, BorderLayout.NORTH );
panel1.add ( p3, BorderLayout.WEST );
panel1.add ( j1, BorderLayout.EAST );
panel1.add ( d1, BorderLayout.SOUTH );
JPanel panel2 = new JPanel ( );
panel2.setLayout ( new BorderLayout ( ) );
JPanel pk2 = new JPanel();
pk2.setBackground(new Color(255, 204, 0));
JLabel k2 = new JLabel("Welcome to BallsMarket ", JLabel.CENTER);
k2.setFont(myFont.deriveFont(Font.PLAIN,30));
k2.setForeground(new Color(204, 51, 0));
pk2.add(k2);
JButton b4 = new JButton("Pokeball");
b4.addActionListener(new ActionListener(){
//anonymous class
public void actionPerformed(ActionEvent e) {
addBall(pokeball);
//System.out.println(pokeball);
}
});
JButton b5 = new JButton("Quickball");
b5.addActionListener(new ActionListener(){
//anonymous class
public void actionPerformed(ActionEvent e) {
addBall(quickball);
//System.out.println(quickball);
}
});
JButton b7 = new JButton("Ultraball");
b7.addActionListener(new ActionListener(){
//anonymous class
public void actionPerformed(ActionEvent e) {
addBall(ultraball);
// System.out.println(ultraball);
}
});
JButton d2 = new JButton("CLOSE");
d2.addActionListener(new ActionListener(){
//anonymous class
public void actionPerformed(ActionEvent e) {
System.out.println(balls);
Bag.ball = balls;
System.out.println(Bag.ball);
setVisible(false);
}
});
JPanel p4 = new JPanel();
p4.setLayout(new BoxLayout(p4, BoxLayout.Y_AXIS));
b4.add(Box.createRigidArea(new Dimension(150, 52)));
b5.add(Box.createRigidArea(new Dimension(150, 52)));
b7.add(Box.createRigidArea(new Dimension(150, 52)));
p4.add(b4);
p4.add(b7);
p4.add(b5);
JLabel j2 = new JLabel(new ImageIcon("img/ball.png"));
panel2.add ( pk2, BorderLayout.NORTH );
panel2.add ( p4, BorderLayout.EAST );
panel2.add ( j2, BorderLayout.CENTER );
panel2.add ( d2, BorderLayout.SOUTH );
JTabbedPane tabbedPane = new JTabbedPane ( );
tabbedPane.setSize ( 750, 420 );
tabbedPane.setLocation ( 30, 10 );
c.add ( tabbedPane );
tabbedPane.addTab ( "Berrie", panel1 );
tabbedPane.setBackgroundAt ( 0, Color.ORANGE );
tabbedPane.setForegroundAt ( 0, Color.BLACK);
tabbedPane.addTab ( "POKEMON BALLS", panel2);
tabbedPane.setBackgroundAt ( 1, Color.YELLOW );
tabbedPane.setForegroundAt ( 1, Color.BLACK );
setSize ( 780, 460 );
setVisible ( true );
}
public void addBerry(Berries berrie){
int berry = berrie.getNum()+1;
berrie.setNum(berry);
System.out.println("" + berrie.getType() + " have " + berrie.getNum());
}
public void addBall(Ball ball){
int b= ball.getNumber()+1;
ball.setNumber(b);
System.out.println(ball);
}
}