-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProperty.java
More file actions
98 lines (74 loc) · 1.65 KB
/
Copy pathProperty.java
File metadata and controls
98 lines (74 loc) · 1.65 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
public class Property extends Square {
private static final float MORTGAGE_PREMIUM = 1.1f;
private boolean isOwned;
private int price;
private Player owner;
private String shortName;
private boolean mortgaged;
private int mortgageValue;
Property (String name, int price, String shortName, int mortgageValue) {
super(name);
this.price = price;
this.shortName = shortName;
isOwned = false;
owner = null;
mortgaged = false;
this.mortgageValue = mortgageValue;
return;
}
// METHODS DEALING WITH NAMES
public String getShortName () {
return shortName;
}
// METHODS DEALING WITH PRICE
public int getPrice () {
return price;
}
// METHODS DEALING WITH RENT :
public int getRent () { // this method is overloaded by the subclasses
return 0;
}
// METHODS DEALING WITH OWNERSHIP
public Player getOwner () {
return owner;
}
public boolean isOwned () {
return isOwned;
}
public void setOwner (Player player) {
owner = player;
isOwned = true;
return;
}
public void releaseOwnership () {
isOwned = false;
owner = null;
mortgaged = false;
return;
}
// METHODS DEALING WITH MORTGAGES
public void setMortgaged() {
mortgaged = true;
return;
}
public boolean isMortgaged() {
return mortgaged;
}
public void setNotMortgaged() {
mortgaged = false;
return;
}
public int getMortgageValue() {
return mortgageValue;
}
public int getMortgageRemptionPrice () {
return (int) (((float) mortgageValue) * MORTGAGE_PREMIUM);
}
// COMMON JAVA METHODS
public boolean equals (String string) {
return shortName.equals(string);
}
public String toString () {
return super.toString();
}
}