package modern.challenge; import java.util.Objects; public class MutableMelon { private String type; private int weight; public MutableMelon(String type, int weight) { this.type = type; this.weight = weight; } public String getType() { return type; } public int getWeight() { return weight; } public void setType(String type) { this.type = type; } public void setWeight(int weight) { this.weight = weight; } @Override public int hashCode() { int hash = 5; hash = 79 * hash + Objects.hashCode(this.type); hash = 79 * hash + this.weight; return hash; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final MutableMelon other = (MutableMelon) obj; if (this.weight != other.weight) { return false; } if (!Objects.equals(this.type, other.type)) { return false; } return true; } @Override public String toString() { return type + "(" + weight + "g)"; } }