package de.kwirz.yapne.model;

/**
 * Created by konstantin on 26/11/14.
 */
public class PetriNetPlace extends PetriNetNode {
    private int marking = 0;

    public PetriNetPlace(final String id) {
        super(id);
    }

    public int getMarking() {
        return marking;
    }

    public void setMarking(int marking) {
        if (marking < 0) {
            throw new IllegalArgumentException("marking cannot be negative");
        }
        this.marking = marking;
    }

    @Override
    public String toXml() {
        return String.format("<place id=\"%s\">\n" +
                "<name>\n" +
                "<value>%s</value>\n" +
                "</name>\n" +
                "<initialMarking>\n" +
                "<token>\n" +
                "<value>%d</value>\n" +
                "</token>\n" +
                "</initialMarking>\n" +
                "<graphics>\n" +
                "%s\n" +
                "</graphics>\n" +
                "</place>", getId(), getName(), getMarking(), getPosition().toXml());
    }
}

@@ -1034,11 +1034,231 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public String toString() %7B%0A        return String.format(%22%25s %7Bid=%25s, name='%25s', marking=%25d, pos=%25s%7D%22,%0A                getClass().getSimpleName(), getId(), getName(), getMarking(), getPosition());%0A    %7D
 %0A%7D%0A

add toString method