parent
76f7f49812
commit
788791c52f
@ -0,0 +1,31 @@
|
|||||||
|
package com.example.tankbattle.decorator;
|
||||||
|
|
||||||
|
import com.example.tankbattle.GameObject;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
|
||||||
|
public class GODecorator extends GameObject {
|
||||||
|
GameObject gameObject;
|
||||||
|
|
||||||
|
public GODecorator(GameObject gameObject) {
|
||||||
|
this.gameObject = gameObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
this.x = gameObject.x;
|
||||||
|
this.y = gameObject.y;
|
||||||
|
paint(g);
|
||||||
|
gameObject.paint(g);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getWidth() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHeight() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.example.tankbattle.decorator;
|
||||||
|
|
||||||
|
import com.example.tankbattle.GameObject;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
|
||||||
|
public class RectDecorator extends GameObject {
|
||||||
|
GameObject gameObject;
|
||||||
|
|
||||||
|
public RectDecorator(GameObject gameObject) {
|
||||||
|
this.gameObject = gameObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
this.x = gameObject.x;
|
||||||
|
this.y = gameObject.y;
|
||||||
|
|
||||||
|
gameObject.paint(g);
|
||||||
|
|
||||||
|
Color c = g.getColor();
|
||||||
|
g.setColor(Color.YELLOW);
|
||||||
|
g.drawRect(x, y, gameObject.getWidth(), gameObject.getHeight());
|
||||||
|
g.setColor(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getWidth() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHeight() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue