fr_b02 / petri / src / arc / ArcCleaner.java @ 3
Historique | Voir | Annoter | Télécharger (1,281 ko)
1 |
package arc; |
---|---|
2 |
|
3 |
import element.Place; |
4 |
|
5 |
public class ArcCleaner extends Arc{ |
6 |
|
7 |
|
8 |
public ArcCleaner(Place place) {
|
9 |
super(place);
|
10 |
|
11 |
} |
12 |
|
13 |
public void doTransition() { |
14 |
if (this.isActive()==true) { |
15 |
this.getPlace().changeToken(-this.getPlace().getToken()); |
16 |
} |
17 |
} |
18 |
|
19 |
public boolean isActive() { |
20 |
return (this.getPlace().getToken()>0); |
21 |
} |
22 |
|
23 |
public boolean isPullable() { |
24 |
return this.isActive(); |
25 |
} |
26 |
public String toString() { |
27 |
return "ArcCleaner,"+this.getPlace(); |
28 |
} |
29 |
public static void main(String[] args) { |
30 |
System.out.println("TEST METHODS ARCCLEANER"); |
31 |
|
32 |
System.out.println(" => method isActive()"); |
33 |
Place emptyPlace = new Place(0); |
34 |
ArcCleaner arcc1 = new ArcCleaner(emptyPlace);
|
35 |
Place place3 = new Place(3); |
36 |
ArcCleaner arcc2 = new ArcCleaner(place3);
|
37 |
System.out.println("false : "+arcc1.isActive()); |
38 |
System.out.println("true : "+arcc2.isActive()); |
39 |
|
40 |
|
41 |
System.out.println(" => method isPullable()"); |
42 |
System.out.println(arcc1);
|
43 |
System.out.println("false : "+arcc1.isPullable()); |
44 |
System.out.println(arcc2);
|
45 |
System.out.println("true : "+arcc2.isPullable()); |
46 |
|
47 |
System.out.println(" => method doTranstion()"); |
48 |
System.out.println("before : "+arcc2); |
49 |
arcc2.doTransition(); |
50 |
System.out.println("after : "+arcc2); |
51 |
|
52 |
} |
53 |
|
54 |
|
55 |
|
56 |
} |