docs: double dispatch explanation + refactor (#2915)

This commit is contained in:
Ilkka Seppälä
2024-04-13 08:30:48 +03:00
committed by GitHub
parent 9240d80ef2
commit 825d45b086
4 changed files with 100 additions and 25 deletions
@@ -24,9 +24,14 @@
*/
package com.iluwatar.doubledispatch;
import lombok.Getter;
import lombok.Setter;
/**
* Game objects have coordinates and some other status information.
*/
@Getter
@Setter
public abstract class GameObject extends Rectangle {
private boolean damaged;
@@ -42,22 +47,6 @@ public abstract class GameObject extends Rectangle {
super.toString(), isDamaged(), isOnFire());
}
public boolean isOnFire() {
return onFire;
}
public void setOnFire(boolean onFire) {
this.onFire = onFire;
}
public boolean isDamaged() {
return damaged;
}
public void setDamaged(boolean damaged) {
this.damaged = damaged;
}
public abstract void collision(GameObject gameObject);
public abstract void collisionResolve(FlamingAsteroid asteroid);
@@ -35,7 +35,6 @@ class AppTest {
/**
* Issue: Add at least one assertion to this test case.
*
* Solution: Inserted assertion to check whether the execution of the main method in {@link App#main(String[])}
* throws an exception.
*/
@@ -52,7 +52,7 @@ class RectangleTest {
* #toString()}
*/
@Test
void testToString() throws Exception {
void testToString() {
final var rectangle = new Rectangle(1, 2, 3, 4);
assertEquals("[1,2,3,4]", rectangle.toString());
}