Statistiques
| Révision:

fr_b02 / petri / src / element / Place.java @ 4

Historique | Voir | Annoter | Télécharger (817 octets)

1 3 a19coudr
package element;
2 2 a19coudr
3 4 a19coudr
4
5 2 a19coudr
public class Place {
6
7
        private int token;
8
9 4 a19coudr
        @SuppressWarnings("serial")
10
        public class UndefinedToken extends Exception{
11
                public UndefinedToken() {
12
                        super("the token cannot take a value <0");
13
                }
14
15
        }
16
17
        public Place(int token) throws UndefinedToken{
18
                if(token<0) {
19
                        throw new UndefinedToken();
20
                }
21 2 a19coudr
                this.token=token;
22
        }
23
24
        public int getToken() {
25
                return this.token;
26
        }
27
        public String toString() {
28
                return "Place Token : "+token;
29
        }
30
31
        public boolean isEmpty() {
32
                return (this.token==0);
33
        }
34
35
        public void changeToken(int i) {
36
                token += i;
37
        }
38
39
        public boolean equals(Object o) {
40
                if((o instanceof Place) &&(System.identityHashCode(((Place)o))==System.identityHashCode(this))) {
41
                        return true;
42
                }
43
                else {
44
                        return false;
45
                }
46
        }
47
48
}