You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
948 B

  1. package program;
  2. import expression.Expression;
  3. import expression.Identifier;
  4. public class Assignment extends Program {
  5. public final Identifier identifier;
  6. public final Expression expression;
  7. @Override
  8. public boolean equals(Object o) {
  9. if (this == o) return true;
  10. if (o == null || getClass() != o.getClass()) return false;
  11. Assignment that = (Assignment) o;
  12. if (!identifier.equals(that.identifier)) return false;
  13. return expression.equals(that.expression);
  14. }
  15. @Override
  16. public String toString() {
  17. return identifier + " := " + expression;
  18. }
  19. @Override
  20. public int hashCode() {
  21. int result = identifier.hashCode();
  22. result = 31 * result + expression.hashCode();
  23. return result;
  24. }
  25. public Assignment(Identifier identifier, Expression expression) {
  26. this.identifier = identifier;
  27. this.expression = expression;
  28. }
  29. }