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