public class Main {
public static void main(String arg[]) {
- try {
- var parser = new PetrinetParser(System.in);
+ try (var parser = new PetrinetParser(System.in)) {
var net = parser.read();
+ // test code
net.step(2);
-
System.out.println(Arrays.asList(net.getMarking()).toString());
} catch (IOException ex) {
System.err.println("Error: "+ex.getMessage());
import java.util.Random;
import java.util.stream.Collectors;
-public final class PetriNet {
+public final class Petrinet {
private static final class Place {
final private Place[] places;
final private List<Transition> transitions;
- public PetriNet(int places) {
+ public Petrinet(int places) {
this.places = new Place[places];
for (int i = 0 ; i < places ; i++)
this.places[i] = new Place();
}
}
- public PetriNet read() throws IOException {
- PetriNet result = null;
+ public Petrinet read() throws IOException {
+ Petrinet result = null;
String input;
int line = 0;
case COMMENT: break;
case PLACES:
if (result == null) {
- result = new PetriNet(parsedLine.val0);
+ result = new Petrinet(parsedLine.val0);
} else {
throw new IOException("places command must occur once");
}
}
@Override
- public void close() throws Exception {
+ public void close() throws IOException {
reader.close();
}
}