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.
Demo1/src/MathQuestion.java

40 lines
875 B

/**
* 数学题目类
* 存储题目表达式和答案
*/
public class MathQuestion {
private String expression;
private String answer;
public MathQuestion(String expression, String answer) {
this.expression = expression;
this.answer = answer;
}
public String getExpression() {
return expression;
}
public String getAnswer() {
return answer;
}
@Override
public String toString() {
return expression;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
MathQuestion that = (MathQuestion) obj;
return expression.equals(that.expression);
}
@Override
public int hashCode() {
return expression.hashCode();
}
}