mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 14:59:25 +00:00
Changed package naming across all examples.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package com.iluwatar.doubledispatch;
|
||||
|
||||
/**
|
||||
*
|
||||
* Space station Mir game object
|
||||
*
|
||||
*/
|
||||
public class SpaceStationMir extends GameObject {
|
||||
|
||||
public SpaceStationMir(int left, int top, int right, int bottom) {
|
||||
super(left, top, right, bottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collision(GameObject gameObject) {
|
||||
gameObject.collisionResolve(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collisionResolve(FlamingAsteroid asteroid) {
|
||||
System.out.println(String.format("%s hits %s. %s is damaged! %s is set on fire!",
|
||||
asteroid.getClass().getSimpleName(), this.getClass().getSimpleName(),
|
||||
this.getClass().getSimpleName(), this.getClass().getSimpleName()));
|
||||
setDamaged(true);
|
||||
setOnFire(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collisionResolve(Meteoroid meteoroid) {
|
||||
System.out.println(String.format("%s hits %s. %s is damaged!",
|
||||
meteoroid.getClass().getSimpleName(), this.getClass().getSimpleName(),
|
||||
this.getClass().getSimpleName()));
|
||||
setDamaged(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collisionResolve(SpaceStationMir mir) {
|
||||
System.out.println(String.format("%s hits %s. %s is damaged!",
|
||||
mir.getClass().getSimpleName(), this.getClass().getSimpleName(),
|
||||
this.getClass().getSimpleName()));
|
||||
setDamaged(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collisionResolve(SpaceStationIss iss) {
|
||||
System.out.println(String.format("%s hits %s. %s is damaged!",
|
||||
iss.getClass().getSimpleName(), this.getClass().getSimpleName(),
|
||||
this.getClass().getSimpleName()));
|
||||
setDamaged(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user