Пример #1
0
 public List<Place> getMarkedPlaces() {
   List<Place> places = new ArrayList<Place>();
   for (Place p : net.getPlaces()) {
     if (getNumTokens(p) > 0) places.add(p);
   }
   return places;
 }
Пример #2
0
 protected boolean hasTokenOnIntermediatePlace() {
   for (Place place : net.getPlaces()) {
     if (!place.isFinalPlace() && this.getNumTokens(place) > 0) {
       return true;
     }
   }
   return false;
 }
Пример #3
0
  protected boolean hasOneTokenOnFinalPlace() {
    for (Place place : net.getPlaces()) {
      if (place.isFinalPlace() && this.getNumTokens(place) == 1) {
        return true;
      }
    }

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

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

    return marking;
  }
Пример #5
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;
 }
Пример #6
0
 public Place findUnsafePlace() {
   for (Place p : net.getPlaces()) {
     if (getNumTokens(p) > 1) return p;
   }
   return null;
 }