@Test public void testEquals() { LotteryTicketCheckResult result1 = new LotteryTicketCheckResult(CheckResult.NO_PRIZE); LotteryTicketCheckResult result2 = new LotteryTicketCheckResult(CheckResult.NO_PRIZE); assertEquals(result1, result2); LotteryTicketCheckResult result3 = new LotteryTicketCheckResult(CheckResult.WIN_PRIZE, 300000); assertFalse(result1.equals(result3)); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } LotteryTicketCheckResult other = (LotteryTicketCheckResult) obj; return checkResult == other.checkResult && prizeAmount == other.prizeAmount; }
LotteryTicketCheckResult { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } LotteryTicketCheckResult other = (LotteryTicketCheckResult) obj; return checkResult == other.checkResult && prizeAmount == other.prizeAmount; } }
LotteryTicketCheckResult { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } LotteryTicketCheckResult other = (LotteryTicketCheckResult) obj; return checkResult == other.checkResult && prizeAmount == other.prizeAmount; } LotteryTicketCheckResult(CheckResult result);  LotteryTicketCheckResult(CheckResult result, int amount); }
LotteryTicketCheckResult { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } LotteryTicketCheckResult other = (LotteryTicketCheckResult) obj; return checkResult == other.checkResult && prizeAmount == other.prizeAmount; } LotteryTicketCheckResult(CheckResult result);  LotteryTicketCheckResult(CheckResult result, int amount); CheckResult getResult(); int getPrizeAmount(); @Override int hashCode(); @Override boolean equals(Object obj); }
LotteryTicketCheckResult { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } LotteryTicketCheckResult other = (LotteryTicketCheckResult) obj; return checkResult == other.checkResult && prizeAmount == other.prizeAmount; } LotteryTicketCheckResult(CheckResult result);  LotteryTicketCheckResult(CheckResult result, int amount); CheckResult getResult(); int getPrizeAmount(); @Override int hashCode(); @Override boolean equals(Object obj);  }