-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProperty.java
More file actions
233 lines (189 loc) · 6.33 KB
/
Property.java
File metadata and controls
233 lines (189 loc) · 6.33 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
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
public class Property extends JPanel implements MouseMotionListener{
JTextArea northField = new JTextArea();
JTextPane centerArea = new JTextPane();
String name;
Player owner;
Color propertyColor;
boolean owned, isMortgaged;
JPanel colorMonitor = new JPanel(new GridLayout(2,2));
JTextArea[] colors = new JTextArea[4];
int pricePerHouse, standardRent, oneHouseRent, twoHouseRent, threeHouseRent, fourHouseRent, hotelRent, mortgageValue, costToBuy,numHouses,numHotels,manageIndex;
Border compound = BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder());
public int getManageIndex(){
return manageIndex;
}
public void setManageIndex(int manageIndex){
this.manageIndex = manageIndex;
}
public Property(Color propertyColor, String name, int pricePerHouse, int standardRent, int oneHouseRent, int twoHouseRent, int threeHouseRent, int fourHouseRent, int hotelRent, int mortgageValue, boolean owned,boolean isMortgaged, Player owner, int costToBuy, int numHouses, int numHotels, int manageIndex){
this.name = name;
this.manageIndex=manageIndex;
this.numHouses=numHouses;
this.costToBuy=costToBuy;
this.owner=owner;
this.owned=owned;
this.pricePerHouse=pricePerHouse;
this.standardRent=standardRent;
this.oneHouseRent=oneHouseRent;
this.twoHouseRent=twoHouseRent;
this.threeHouseRent=threeHouseRent;
this.fourHouseRent=fourHouseRent;
this.hotelRent=hotelRent;
this.mortgageValue = mortgageValue;
this.propertyColor = propertyColor;
this.setLayout(new BorderLayout());
this.add(northField, BorderLayout.NORTH);
northField.setBackground(propertyColor);
northField.setEnabled(false);
this.add(colorMonitor, BorderLayout.CENTER);
for(int i=0; i<4; i++){
colors[i] = new JTextArea();
colors[i].setEnabled(false);
colorMonitor.add(colors[i]);
colors[i].setBorder(new TitledBorder(""));
colors[i].addMouseMotionListener(this);
}
}
public int getNumHouses(){
return numHouses;
}
public void setNumHouses(int numHouses){
this.numHouses = numHouses;
}
public int getNumHotels(){
return numHotels;
}
public void setNumHotels(int numHotels){
this.numHotels = numHotels;
}
public int getCostToBuy(){
return costToBuy;
}
public void setCostToBuy(int costToBuy){
this.costToBuy = costToBuy;
}
public int getPricePerHouse(){
return pricePerHouse;
}
public Player getOwner(){
return owner;
}
public void setOwner(Player owner){
this.owner=owner;
}
public void insertText(String text){
centerArea.setText(text);
}
public void setImage(String path){
centerArea.insertIcon(new ImageIcon(path));
}
public void setPricePerHouse(int pricePerHouse){
this.pricePerHouse = pricePerHouse;
}
public void setStandardRent(int standardRent){
this.standardRent = standardRent;
}
public void setOneHouseRent(int oneHouseRent){
this.oneHouseRent = oneHouseRent;
}
public void setTwoHouseRent(int twoHouseRent){
this.twoHouseRent = twoHouseRent;
}
public void setThreeHouseRent(int threeHouseRent){
this.threeHouseRent = threeHouseRent;
}
public void setFourHouseRent(int fourHouseRent){
this.fourHouseRent = fourHouseRent;
}
public void setHotelRent(int hotelRent){
this.hotelRent = hotelRent;
}
public void setMortgageValue(int mortgageValue){
this.mortgageValue=mortgageValue;
}
public int getStandardRent(){
return standardRent;
}
public int getOneHouseRent(){
return oneHouseRent;
}
public int getTwoHouseRent(){
return twoHouseRent;
}
public int getThreeHouseRent(){
return threeHouseRent;
}
public int getFourHouseRent(){
return fourHouseRent;
}
public boolean isMortgaged(){
return isMortgaged;
}
public void setMortgageState(boolean mortgaged){
this.isMortgaged=mortgaged;
}
public int getHotelRent(){
return hotelRent;
}
public int getMortgageValue(){
return mortgageValue;
}
public boolean isOwned(){
return owned;
}
public void setOwned(boolean owned){
this.owned=owned;
}
public void setBackgroundColor(Color backColor){
northField.setBackground(backColor);
this.propertyColor=backColor;
}
public void workAround(Color color){
this.setBackground(color);
}
public Color getBackgroundColor(){
return this.propertyColor;
}
public void setBorders(Border border){
northField.setBorder(border);
this.setBorder(border);
}
public void setName(String name){
this.name = name;
}
public String getName(){
return this.name;
}
public void buyHouse(int numHouses){
this.numHouses+=numHouses;
}
public void buyHotel(){
this.numHotels+=1;
}
public int getRent(int numHouses, int numHotels){
if(numHouses==0)
return this.standardRent;
else if(numHouses==1)
return this.oneHouseRent;
else if(numHouses==2)
return this.twoHouseRent;
else if(numHouses==3)
return this.threeHouseRent;
else if(numHouses==4)
return this.fourHouseRent;
else if(numHouses==4 && numHotels==1)
return this.hotelRent;
return 0;
}
public void mouseDragged(MouseEvent e){}
public void mouseMoved(MouseEvent e){}
}