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