-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMonopolyBoard.java
188 lines (169 loc) · 6.24 KB
/
MonopolyBoard.java
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
package IT178Monopoly;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
public class MonopolyBoard implements ActionListener, WindowListener {
private static MonopolyPlayer p1 = new MonopolyPlayer("", 1);
private static MonopolyPlayer p2 = new MonopolyPlayer("", 2);
private static JFrame a = new JFrame("Monopoly");
private static JButton b1 = new JButton("Go ");
private static JButton b2 = new JButton("Mediterranian Ave");
private static JButton b3 = new JButton("Baltic Ave");
private static JButton b4 = new JButton("Community Chest");
private static JButton b5 = new JButton("Reading Railroad ");
private static JButton b6 = new JButton("Oriental Ave");
private static JButton b7 = new JButton("Vermont Ave");
private static JButton b8 = new JButton("Connecticut Ave");
private static JButton b9 = new JButton("Get out of Jail!" );
private static JButton b10 = new JButton("St.Charles Place");
private static JButton b11 = new JButton("States Ave");
private static JButton b12 = new JButton("Virginia Ave");
private static JButton b13 = new JButton("Chance");
private static JButton b14 = new JButton ("St.James Ave");
private static JButton b15 = new JButton ("Tennessee Ave");
private static JButton b16 = new JButton ("New York Ave");
private static JButton b17 = new JButton ("Chance");
private static JButton b18 = new JButton ("Park Place");
private static JButton b19 = new JButton ("Chance");
private static JButton b20 = new JButton ("Boardwalk");
private static JTextArea tf1 = new JTextArea("Player 1", 1, 13);
private static JTextArea tf2 = new JTextArea("Player 2", 1, 13);
private static JLabel comments = new JLabel ("Welcome to Monopoly! " );
private static JLabel comments1 = new JLabel ("This game is created by " );
private static JLabel comments2 = new JLabel ("Dr. Tonya Pierce " );
private static JLabel comments3 = new JLabel ("Please enter your names for player 1 and player 2 .");
private static JLabel comments4 = new JLabel (" This is a two player game only! ");
private static JLabel comments5 = new JLabel ("");
public static void main(String[] args){
a.getContentPane().setBackground(Color.BLUE);
a.setSize( 1000, 800);
a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
LayoutManager GridLayout = null;
a.setLayout(new GridLayout(8, 8));
a.setResizable(false);
JPanel buttons1 = new JPanel();
b1.setPreferredSize(new Dimension(100, 60));
buttons1.add(b1);
b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
a.toFront();
if(MonopolyPlayer.getActivePlayer()==1)
p1.setMoney(200);
else
p2.setMoney(200);
}
});
b2.setPreferredSize(new Dimension(100,60));
buttons1.add(b2);
/*b2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
a.toFront();
if(MonopolyPlayer.getActivePlayer() == 1){
if(p2.isOwned(2)){
p2.setMoney(-100);
p1.setMoney(100);
}
else if(!p1.isOwned(2)){
System.out.println("Buying property for $200");
p1.setMoney(-200);
}
}}
});*/
b3.setPreferredSize(new Dimension(100,60));
buttons1.add(b3);
b3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
a.toFront();
}
});
b4.setPreferredSize(new Dimension(100,60));
buttons1.add(b4);
/*b4.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
a.toFront();
}
});*/
b5.setPreferredSize(new Dimension(100,60));
buttons1.add(b5);
//b5.addActionListener((ActionListener) b5);
b6.setPreferredSize(new Dimension(100,60));
buttons1.add(b6);
//b6.addActionListener((ActionListener) b1);
b7.setPreferredSize(new Dimension(100,60));
buttons1.add(b7);
//b7.addActionListener((ActionListener) b1);
b8.setPreferredSize(new Dimension(100,60));
buttons1.add(b8);
//b8.addActionListener((ActionListener) b1);
a.add(buttons1);
b9.setPreferredSize(new Dimension(100,60));
b10.setPreferredSize(new Dimension(100,60));
b11.setPreferredSize(new Dimension(100,60));
b12.setPreferredSize(new Dimension(100,60));
//b8.addActionListener((ActionListener) b1);
JPanel mainstuff = new JPanel();
mainstuff.setPreferredSize(new Dimension(50,30));
mainstuff.add(b9);
mainstuff.add(comments);
mainstuff.add(comments1);
mainstuff.add(comments2);
mainstuff.add(comments4);
mainstuff.add(comments5);
mainstuff.add(b10);
a.add(mainstuff);
JPanel mainstuff2 = new JPanel();
mainstuff2.add(b11);
mainstuff2.add(comments3);
mainstuff2.add(new Label (" "));
mainstuff2.add(tf1);
mainstuff2.add(tf2);
mainstuff2.add(new Label (" "));
mainstuff2.add(b12);
a.add(mainstuff2);
a.addWindowListener(null);
a.setVisible(true);
}
@Override
public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowClosed(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowClosing(WindowEvent arg0) {
System.exit(0);
}
@Override
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
}
}