Add toString() methods
This commit is contained in:
parent
7b2f8cacf2
commit
6010dc04f3
|
@ -73,4 +73,9 @@ public class Constraint {
|
|||
this.op = op;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "expression: (" + expression + ") strength: " + strength + " operator: " + op;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -68,5 +68,22 @@ public class Expression {
|
|||
public final boolean isConstant() {
|
||||
return terms.size() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("isConstant: " + isConstant() + " constant: " + constant);
|
||||
if (!isConstant()) {
|
||||
sb.append(" terms: [");
|
||||
for (Term term: terms) {
|
||||
sb.append("(");
|
||||
sb.append(term);
|
||||
sb.append(")");
|
||||
}
|
||||
sb.append("] ");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -7,4 +7,7 @@ public class KiwiException extends Exception {
|
|||
public KiwiException() {
|
||||
|
||||
}
|
||||
public KiwiException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,4 +36,9 @@ public class Term {
|
|||
public double getValue() {
|
||||
return coefficient * variable.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "variable: (" + variable + ") coefficient: " + coefficient;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ public class UnsatisfiableConstraintException extends KiwiException {
|
|||
|
||||
private Constraint constraint;
|
||||
public UnsatisfiableConstraintException(Constraint constraint) {
|
||||
super(constraint.toString());
|
||||
this.constraint = constraint;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,4 +27,10 @@ public class Variable {
|
|||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "name: " + name + " value: " + value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue