Statistiques
| Révision:

fr_b02 / petri / src / arc / ArcEntering.java @ 3

Historique | Voir | Annoter | Télécharger (1,526 ko)

1
package arc;
2

    
3
import element.Place;
4

    
5
public class ArcEntering extends Arc{
6
        
7
        private int value;
8

    
9
        public ArcEntering(Place place, int value) {
10
                super(place);
11
                // TODO Auto-generated constructor stub
12
                this.value=value;
13
        }
14
        
15
        public void doTransition() {
16
                this.getPlace().changeToken(this.value);
17
        }
18
        
19
        public boolean isActive() {
20
                return true;
21
        }
22
        
23
        public boolean isPullable() {
24
                return true;
25
        }
26
        public String toString() {
27
                return "ArcEntering value:"+value+", "+this.getPlace();
28
        }
29
        public static void main(String[] args) {
30
                System.out.println("TEST METHODS ARCENTERING");
31
                
32
                System.out.println(" => method isActive()");
33
                Place emptyPlace = new Place(0);
34
                ArcEntering arce = new ArcEntering(emptyPlace, 3);
35
                System.out.println("true : "+arce.isActive());
36

    
37
        
38
                System.out.println(" => method isPullable()");
39
                Place place3 = new Place(3);
40
                ArcEntering arce2 = new ArcEntering(place3, 2);
41
                ArcEntering arce4 = new ArcEntering(place3, 4);
42
                System.out.println(arce2);
43
                System.out.println("true : "+arce2.isPullable());
44
                System.out.println(arce4);
45
                System.out.println("true : "+arce4.isPullable());
46
                
47
                System.out.println(" => method doTranstion()");
48
                System.out.println("before : "+arce2);
49
                arce2.doTransition();
50
                System.out.println("after  : "+arce2);
51
                System.out.println(" => method equals()");
52
                // the method equals is test here because arc is an abstract method
53
                System.out.println("true : "+arce2.equals(arce2));
54
                System.out.println("false : "+arce2.equals(arce4));
55
        }
56
        
57

    
58
}