Revision 477,
1.2 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 SimpleResourceUnit extends AbstractResourceUnit { |
---|
6 | |
---|
7 | protected int total; |
---|
8 | protected int used; |
---|
9 | |
---|
10 | public SimpleResourceUnit(SimpleResourceUnit sru, int total, int used) { |
---|
11 | super(sru); |
---|
12 | this.total = total; |
---|
13 | this.used = used; |
---|
14 | } |
---|
15 | |
---|
16 | public SimpleResourceUnit(SimpleResourceUnit sru) { |
---|
17 | super(sru); |
---|
18 | this.total = sru.total; |
---|
19 | this.used = sru.used; |
---|
20 | } |
---|
21 | |
---|
22 | public SimpleResourceUnit(ResourceUnitName name, int total, int used) { |
---|
23 | super(name); |
---|
24 | this.total = total; |
---|
25 | this.used = used; |
---|
26 | } |
---|
27 | |
---|
28 | public SimpleResourceUnit(ResourceUnitName name, String resId, int total, int used) { |
---|
29 | super(name, resId); |
---|
30 | this.total = total; |
---|
31 | this.used = used; |
---|
32 | } |
---|
33 | |
---|
34 | public int getFreeAmount() { |
---|
35 | return this.total - this.used; |
---|
36 | } |
---|
37 | |
---|
38 | public int getUsedAmount(){ |
---|
39 | return this.used; |
---|
40 | } |
---|
41 | |
---|
42 | public void setUsedAmount(int amount){ |
---|
43 | if(amount > this.total){ |
---|
44 | throw new IllegalArgumentException( |
---|
45 | "Used amount can not be grather then total amount."); |
---|
46 | } |
---|
47 | this.used = amount; |
---|
48 | } |
---|
49 | |
---|
50 | public int getAmount(){ |
---|
51 | return this.total; |
---|
52 | } |
---|
53 | |
---|
54 | public ResourceUnit toDiscrete() throws ClassNotFoundException { |
---|
55 | throw new ClassNotFoundException("There is no distinguish class version for " |
---|
56 | + getClass().getName()); |
---|
57 | } |
---|
58 | |
---|
59 | |
---|
60 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.