-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProperty.java
52 lines (48 loc) · 1.5 KB
/
Property.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
package Monopoly;
class Property extends SquareType{
public Property(String name, int[] rent, int position, int value, int setId, int totalInSet) {
this.setName(name);
this.setRent(rent);
this.setTileType("Property");
this.setPosition(position);
this.setValue(value);
this.setSetId(setId);
this.setTotalInSet(totalInSet);
}
public void landingAction(Player p) {
if (owner == Board.bank) {
buyCard(p);
} else if(owner != p) {
int rent = getRent();
p.payMoney(owner,rent);
}
}
public void addHouse() {
if (numHouses == 5) {
System.out.println("cannot add house - already a hotel");
return;
}
owner.payMoney(Board.bank,((setId+1)/2)*50);
numHouses++;
if (numHouses == 5)
System.out.println("converted to Hotel @ " + name);
else
System.out.println("added a house @ " + name);
Board.updateSquare(this);
Board.printBoard();
}
public void removeHouse() {
if (numHouses == 0) {
System.out.println("No house to sell");
return;
}
Board.bank.payMoney(owner,((setId+1)/2)*25);
if (numHouses == 5)
System.out.println("converted Hotel to 4 houses @ " + name);
else
System.out.println("removed a house @ " + name);
numHouses--;
Board.updateSquare(this);
Board.printBoard();
}
}