@Test public void equals() { class TestCase extends GameEngineTestHelper.ComparisonTestCase<MovePlaying> { TestCase(String name, MovePlaying m1, MovePlaying m2, boolean expected) { super(name, m1, m2, expected); } @Override protected void runAssertions() { assertThat(o1.equals(o2)).as("Check move equality").isEqualTo(expected); } } List<TestCase> testCases = new ArrayList<>( List.of( new TestCase( "As - As", MovePlaying.cardMove(stringToCard("As")), MovePlaying.cardMove(stringToCard("As")), true), new TestCase( "As - Js", MovePlaying.cardMove(stringToCard("As")), MovePlaying.cardMove(stringToCard("Js")), false), new TestCase( "Ts - 9s", MovePlaying.cardMove(stringToCard("Ts")), MovePlaying.cardMove(stringToCard("9s")), false), new TestCase( "As - Ah", MovePlaying.cardMove(stringToCard("As")), MovePlaying.cardMove(stringToCard("Ah")), false), new TestCase( "7c - Tc", MovePlaying.cardMove(stringToCard("7c")), MovePlaying.cardMove(stringToCard("Tc")), false), new TestCase( "7c - Ad", MovePlaying.cardMove(stringToCard("7c")), MovePlaying.cardMove(stringToCard("Ad")), false), new TestCase( "Qc - Qc", MovePlaying.cardMove(stringToCard("Qc")), MovePlaying.cardMove(stringToCard("Qc")), true), new TestCase( "Jh - Jd", MovePlaying.cardMove(stringToCard("Jh")), MovePlaying.cardMove(stringToCard("Jd")), false), new TestCase( "8c - 8c", MovePlaying.cardMove(stringToCard("8c")), MovePlaying.cardMove(stringToCard("8c")), true), new TestCase( "Jd - Qd", MovePlaying.cardMove(stringToCard("Jd")), MovePlaying.cardMove(stringToCard("Qd")), false), new TestCase( "Td - Qd", MovePlaying.cardMove(stringToCard("Td")), MovePlaying.cardMove(stringToCard("Qd")), false), new TestCase( "Ad - Qd", MovePlaying.cardMove(stringToCard("Ad")), MovePlaying.cardMove(stringToCard("Ad")), true), new TestCase( "9s - 9c", MovePlaying.cardMove(stringToCard("9s")), MovePlaying.cardMove(stringToCard("9c")), false))); testCases.forEach(TestCase::run); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (!(obj instanceof MovePlaying)) { return false; } MovePlaying otherMove = (MovePlaying) obj; return this.card.equals(otherMove.card); }
MovePlaying extends Move implements Comparable<MovePlaying> { @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (!(obj instanceof MovePlaying)) { return false; } MovePlaying otherMove = (MovePlaying) obj; return this.card.equals(otherMove.card); } }
MovePlaying extends Move implements Comparable<MovePlaying> { @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (!(obj instanceof MovePlaying)) { return false; } MovePlaying otherMove = (MovePlaying) obj; return this.card.equals(otherMove.card); } private  MovePlaying(Card card); }
MovePlaying extends Move implements Comparable<MovePlaying> { @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (!(obj instanceof MovePlaying)) { return false; } MovePlaying otherMove = (MovePlaying) obj; return this.card.equals(otherMove.card); } private  MovePlaying(Card card); static MovePlaying cardMove(Card card); @Override int compareTo(MovePlaying o); @Override boolean equals(Object obj); @Override String getShortName(); @Override String toString(); }
MovePlaying extends Move implements Comparable<MovePlaying> { @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (!(obj instanceof MovePlaying)) { return false; } MovePlaying otherMove = (MovePlaying) obj; return this.card.equals(otherMove.card); } private  MovePlaying(Card card); static MovePlaying cardMove(Card card); @Override int compareTo(MovePlaying o); @Override boolean equals(Object obj); @Override String getShortName(); @Override String toString();  }