Пример #1
0
 protected boolean hasTokenOnIntermediatePlace() {
   for (Place place : net.getPlaces()) {
     if (!place.isFinalPlace() && this.getNumTokens(place) > 0) {
       return true;
     }
   }
   return false;
 }
Пример #2
0
  protected boolean hasOneTokenOnFinalPlace() {
    for (Place place : net.getPlaces()) {
      if (place.isFinalPlace() && this.getNumTokens(place) == 1) {
        return true;
      }
    }

    return false;
  }
Пример #3
0
  public JSONObject toJson() throws JSONException {
    JSONObject marking = new JSONObject();

    for (Place place : net.getPlaces()) {
      marking.put(place.getResourceId(), this.getNumTokens(place));
    }

    return marking;
  }
Пример #4
0
 public String toString() {
   if (markingStr == null) {
     StringBuilder str = new StringBuilder();
     str.append("{");
     boolean firstEntry = true;
     for (Place p : net.getPlaces()) {
       int numt = getNumTokens(p);
       if (numt > 0) {
         if (firstEntry) firstEntry = false;
         else str.append(",");
         str.append(p.getId());
         if (numt > 1) str.append(":").append(numt);
       }
     }
     str.append("}");
     markingStr = str.toString();
   }
   return markingStr;
 }