Revision 477,
1.3 KB
checked in by wojtekp, 13 years ago
(diff) |
|
-
Property svn:mime-type set to
text/plain
|
Line | |
---|
1 | package schedframe.resources.units; |
---|
2 | |
---|
3 | |
---|
4 | |
---|
5 | public class Cost extends AbstractResourceUnit { |
---|
6 | |
---|
7 | protected int value; |
---|
8 | |
---|
9 | public Cost(Cost c) { |
---|
10 | super(c); |
---|
11 | this.value = c.value; |
---|
12 | } |
---|
13 | |
---|
14 | public Cost(int value) { |
---|
15 | super(StandardResourceUnitName.COST); |
---|
16 | this.value = value; |
---|
17 | } |
---|
18 | |
---|
19 | public Cost(String resId, int value) { |
---|
20 | super(StandardResourceUnitName.COST, resId); |
---|
21 | this.value = value; |
---|
22 | } |
---|
23 | |
---|
24 | public int getFreeAmount() { |
---|
25 | return 0; |
---|
26 | } |
---|
27 | |
---|
28 | public int getUsedAmount(){ |
---|
29 | return 0; |
---|
30 | } |
---|
31 | |
---|
32 | public void setUsedAmount(int amount){ |
---|
33 | } |
---|
34 | |
---|
35 | public int getAmount(){ |
---|
36 | return this.value; |
---|
37 | } |
---|
38 | |
---|
39 | public ResourceUnit toDiscrete() throws ClassNotFoundException { |
---|
40 | throw new ClassNotFoundException("There is no distinguish class version for " |
---|
41 | + getClass().getName()); |
---|
42 | } |
---|
43 | |
---|
44 | /** |
---|
45 | * Comparing two Memory objects is equivalent to |
---|
46 | * comparing the free amount of the resource. See {@link #getAmount()} |
---|
47 | */ |
---|
48 | public int compareTo(ResourceUnit o) { |
---|
49 | if(o instanceof Cost){ |
---|
50 | if(this.value < o.getAmount()) return -1; |
---|
51 | if(this.value > o.getAmount()) return 1; |
---|
52 | return 0; |
---|
53 | } else { |
---|
54 | throw new IllegalArgumentException(o + " is not an instance of " + |
---|
55 | "memory resource unit."); |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | public boolean equals(Object o){ |
---|
60 | if(o instanceof Cost){ |
---|
61 | return super.equals(o); |
---|
62 | } else { |
---|
63 | return false; |
---|
64 | } |
---|
65 | } |
---|
66 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.