fr_b02 / petri / src / element / Transition.java @ 7
Historique | Voir | Annoter | Télécharger (1,047 ko)
1 | 3 | a19coudr | package element; |
---|---|---|---|
2 | 2 | a19coudr | |
3 | import java.util.ArrayList; |
||
4 | import java.util.List; |
||
5 | |||
6 | 4 | a19coudr | import arcElement.Arc; |
7 | 3 | a19coudr | |
8 | 4 | a19coudr | |
9 | 2 | a19coudr | public class Transition { |
10 | |||
11 | |||
12 | private List<Arc> arcList; |
||
13 | 7 | a19coudr | /**
|
14 | * @return a string representation of a transition
|
||
15 | */
|
||
16 | 2 | a19coudr | 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 | 7 | a19coudr | /**
|
30 | * check if the transition is pullable
|
||
31 | * @return true if all its arcs are pullable
|
||
32 | */
|
||
33 | 2 | a19coudr | 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 | 7 | a19coudr | /**
|
43 | *
|
||
44 | * do the transition
|
||
45 | * (all its arcs do the transition
|
||
46 | */
|
||
47 | 2 | a19coudr | 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 | } |