Class Place
java.lang.Object
org.tweetyproject.logics.petri.syntax.PetriNetNode
org.tweetyproject.logics.petri.syntax.Place
- All Implemented Interfaces:
Comparable<Place>,Node
A class to describe places in a Petri net
- Author:
- Benedikt Knopp
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTokens(int tokens) booleancanAddTokens(int tokens) booleancanRemoveTokens(int tokens) intgetId()intintbooleanisFinal()check if this place is a designated final placebooleancheck if this place is a designated initial placevoidremoveTokens(int tokens) voidsetFinal()specify that this place is a designated final placevoidvoidspecify that this place is a designated initial placevoidsetMaxtokens(int maxtokens) voidsetTokens(int tokens) Methods inherited from class org.tweetyproject.logics.petri.syntax.PetriNetNode
getName, setName
-
Constructor Details
-
Place
Create a new instance- Parameters:
id- a unique identifier
-
Place
Create a new instance- Parameters:
id- a unique identifiername- a pretty name
-
-
Method Details
-
getId
- Overrides:
getIdin classPetriNetNode- Returns:
- the id
-
setId
- Overrides:
setIdin classPetriNetNode- Parameters:
id- the id to set
-
getTokens
public int getTokens()- Returns:
- the number of tokens currently at this place
-
setTokens
public void setTokens(int tokens) - Parameters:
tokens- the number of tokens currently at this place
-
getMaxtokens
public int getMaxtokens()- Returns:
- the maximal number of tokens that this place can hold
-
setMaxtokens
public void setMaxtokens(int maxtokens) - Parameters:
maxtokens- the maximal number of tokens that this place can hold
-
addTokens
public void addTokens(int tokens) - Parameters:
tokens- the number of tokens to be added to this place- Throws:
IllegalArgumentException- if this number of tokens can not be added
-
removeTokens
public void removeTokens(int tokens) - Parameters:
tokens- the number of tokens to be removed from this place- Throws:
IllegalArgumentException- if this number of tokens can not be removed
-
canAddTokens
public boolean canAddTokens(int tokens) - Parameters:
tokens- the number of tokens to be added to this place- Returns:
- true if this number can be added with respect to the token limit and the current number of tokens
-
canRemoveTokens
public boolean canRemoveTokens(int tokens) - Parameters:
tokens- the number of tokens to be removed from this place- Returns:
- true if this number can be removed with respect to current number of tokens
-
compareTo
- Specified by:
compareToin interfaceComparable<Place>
-
isInitial
public boolean isInitial()check if this place is a designated initial place- Returns:
- true iff this place is a designated initial place
-
setInitial
public void setInitial()specify that this place is a designated initial place -
isFinal
public boolean isFinal()check if this place is a designated final place- Returns:
- true iff this place is a designated final place
-
setFinal
public void setFinal()specify that this place is a designated final place
-