интерфейс
This commit is contained in:
parent
e5a1bec005
commit
82055e73fe
45
DrawningMotorShip.java
Normal file
45
DrawningMotorShip.java
Normal file
@ -0,0 +1,45 @@
|
||||
import java.awt.*;
|
||||
|
||||
public class DrawningMotorShip extends DrawingShip {
|
||||
public DrawningMotorShip(int speed, float weight, Color bodyColor, Color dopColor, boolean tubes, boolean cistern)
|
||||
{
|
||||
super(speed, weight, bodyColor, 150, 75);
|
||||
warmlyShip = new EntityMotorShip(speed, weight, bodyColor, dopColor, tubes , cistern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DrawTransport(Graphics g)
|
||||
{
|
||||
if (!(warmlyShip instanceof EntityMotorShip motorShip))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.setColor(motorShip.GetDopColor());
|
||||
if (motorShip.GetTubes())
|
||||
{
|
||||
g2d.setColor(motorShip.GetDopColor());
|
||||
g2d.fillRect((int)_startPosX + _warmlyShipWidth / 5, (int)_startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawRect((int)_startPosX + _warmlyShipWidth / 5, (int)_startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2);
|
||||
g2d.setColor(motorShip.GetDopColor());
|
||||
g2d.fillRect((int)_startPosX + _warmlyShipWidth * 3 / 5, (int)_startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawRect((int)_startPosX + _warmlyShipWidth * 3 / 5, (int)_startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2);
|
||||
}
|
||||
|
||||
_startPosY += 25;
|
||||
super.DrawTransport(g);
|
||||
_startPosY -= 25;
|
||||
|
||||
if (motorShip.GetCistern())
|
||||
{
|
||||
g2d.setColor(motorShip.GetDopColor());
|
||||
g2d.fillOval((int)_startPosX, (int)_startPosY + 25, 25, 20);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawOval((int)_startPosX, (int)_startPosY + 25, 25, 20);
|
||||
}
|
||||
}
|
||||
}
|
21
EntityMotorShip.java
Normal file
21
EntityMotorShip.java
Normal file
@ -0,0 +1,21 @@
|
||||
import java.awt.*;
|
||||
|
||||
public class EntityMotorShip extends EntityWarmlyShip {
|
||||
private Color DopColor;
|
||||
private boolean Tubes;
|
||||
private boolean Cistern;
|
||||
|
||||
public EntityMotorShip(int speed, float weight, Color bodyColor, Color dopColor, boolean tubes, boolean cistern)
|
||||
{
|
||||
super(speed, weight, bodyColor);
|
||||
DopColor = dopColor;
|
||||
Tubes = tubes;
|
||||
Cistern = cistern;
|
||||
}
|
||||
|
||||
public Color GetDopColor(){return DopColor;}
|
||||
|
||||
public boolean GetTubes(){return Tubes;}
|
||||
|
||||
public boolean GetCistern(){return Cistern;}
|
||||
}
|
9
IDrawningObject.java
Normal file
9
IDrawningObject.java
Normal file
@ -0,0 +1,9 @@
|
||||
import java.awt.*;
|
||||
|
||||
public interface IDrawningObject {
|
||||
float getStep();
|
||||
void SetObject(int x, int y, int width, int height);
|
||||
void MoveObject(Direction direction);
|
||||
void DrawningObject(Graphics g);
|
||||
float[] GetCurrentPosition();
|
||||
}
|
Loading…
Reference in New Issue
Block a user