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