]> uap-core.de Git - petrinet.git/commitdiff
renames PetriNet to Petrinet and uses the parser as a resource in Main
authorMike Becker <universe@uap-core.de>
Thu, 5 Dec 2019 17:58:06 +0000 (18:58 +0100)
committerMike Becker <universe@uap-core.de>
Thu, 5 Dec 2019 17:58:06 +0000 (18:58 +0100)
src/main/java/de/yasc/example/petrinet/Main.java
src/main/java/de/yasc/example/petrinet/Petrinet.java [moved from src/main/java/de/yasc/example/petrinet/PetriNet.java with 97% similarity]
src/main/java/de/yasc/example/petrinet/PetrinetParser.java

index 8788f763b4b571150c2ac08198dbc1cc2b44e4db..a3b5ca320df6ccc643427bdf5a039b71d1bff34e 100644 (file)
@@ -5,12 +5,11 @@ import java.util.Arrays;
 
 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());
similarity index 97%
rename from src/main/java/de/yasc/example/petrinet/PetriNet.java
rename to src/main/java/de/yasc/example/petrinet/Petrinet.java
index 010a279aa44605c3ba420a55d42241206a79cc63..f8882f247685d2347a25020d72147370a7895520 100644 (file)
@@ -7,7 +7,7 @@ import java.util.List;
 import java.util.Random;
 import java.util.stream.Collectors;
 
-public final class PetriNet {
+public final class Petrinet {
 
     private static final class Place {
 
@@ -51,7 +51,7 @@ public final class PetriNet {
     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();
index 9a70a426ae5a734152ba2e047858cccf23867725..21d63a8dbb8fca5351543616872d24ad3d259e5f 100644 (file)
@@ -112,8 +112,8 @@ public final class PetrinetParser implements AutoCloseable {
         }
     }
 
-    public PetriNet read() throws IOException {
-        PetriNet result = null;
+    public Petrinet read() throws IOException {
+        Petrinet result = null;
 
         String input;
         int line = 0;
@@ -125,7 +125,7 @@ public final class PetrinetParser implements AutoCloseable {
                     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");
                         }
@@ -154,7 +154,7 @@ public final class PetrinetParser implements AutoCloseable {
     }
 
     @Override
-    public void close() throws Exception {
+    public void close() throws IOException {
         reader.close();
     }
 }