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