Statistiques
| Révision:

fr_b02 / petri / src / element / Transition.java @ 7

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

1
package element;
2

    
3
import java.util.ArrayList;
4
import java.util.List;
5

    
6
import arcElement.Arc;
7

    
8

    
9
public class Transition {
10
        
11
        
12
        private List<Arc> arcList;
13
        /**
14
         * @return a string representation of a transition
15
         */
16
        public String toString() {
17
                String res= " [";
18
                for(int i=0;arcList.size()>i;i++ ) {
19
                        res=res+arcList.get(i).toString()+" // ";
20
                }
21
                res=res+"] ";
22
                return res;
23
        }
24

    
25
        public Transition() {
26
                this.arcList=new ArrayList<Arc>();
27
        }
28
        
29
        /**
30
         * check if the transition is pullable
31
         * @return true if all its arcs are pullable
32
         */
33
        public boolean isPullable() {
34
                int i=0;
35
                boolean res=true;
36
                while(i<this.arcList.size() && res==true) {
37
                        res=this.arcList.get(i).isPullable();
38
                        i=i+1;
39
                }
40
                return res;
41
        }
42
        /**
43
         * 
44
         * do the transition 
45
         * (all its arcs do the transition
46
         */
47
        public void doTransition() {
48
                if (this.isPullable()==true) {
49
                        for (int i=0; i<arcList.size();i++) {
50
                                arcList.get(i).doTransition();
51
                        }
52
                }
53
        }
54
        public List<Arc> getArcList(){
55
                return this.arcList;
56
        }
57

    
58

    
59
}