/** * 数学题目类,表示一道数学题 */ public class MathProblem { private String expression; // 题目表达式 private String answer; // 答案 private String difficulty; // 难度级别 public MathProblem(String expression, String answer, String difficulty) { this.expression = expression; this.answer = answer; this.difficulty = difficulty; } public String getExpression() { return expression; } public String getAnswer() { return answer; } public String getDifficulty() { return difficulty; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || getClass() != obj.getClass()) return false; MathProblem that = (MathProblem) obj; return expression.equals(that.expression); } @Override public int hashCode() { return expression.hashCode(); } @Override public String toString() { return expression + " = ?"; } }