mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-20 05:27:15 +00:00
docs: double dispatch explanation + refactor (#2915)
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user