Сданная сложная лаб 1
This commit is contained in:
parent
0a29f09918
commit
ac9d6db704
@ -12,14 +12,15 @@ class DrawningLocomotive {
|
||||
/// Высота окна отрисовки
|
||||
private Integer _pictureHeight = null;
|
||||
/// Ширина отрисовки локомотива
|
||||
private final int _locomotiveWidth = 110;
|
||||
private final int _locomotiveWidth = 120;
|
||||
/// Высота отрисовки локомотива
|
||||
private final int _locomotiveHeight = 50;
|
||||
/// Инициализация свойств
|
||||
public void Init(int speed, float weight, Color bodyColor, int wheelsNum, EntityLocomotive entity)
|
||||
{
|
||||
Locomotive = entity;
|
||||
extraWheelsDraw = new ExtraWheelsDraw(wheelsNum, bodyColor);
|
||||
extraWheelsDraw = new ExtraWheelsDraw();
|
||||
extraWheelsDraw.Init(wheelsNum, bodyColor);
|
||||
Locomotive.Init(speed, weight, bodyColor);
|
||||
}
|
||||
/// Установка позиции локомотива
|
||||
@ -90,7 +91,7 @@ class DrawningLocomotive {
|
||||
}
|
||||
//тело
|
||||
g.setColor(Color.BLACK);
|
||||
g.drawRect((int)_startPosX , (int)_startPosY, _locomotiveWidth - 10, _locomotiveHeight - 10);
|
||||
g.drawRect((int)_startPosX , (int)_startPosY, _locomotiveWidth - 20, _locomotiveHeight - 10);
|
||||
//окна
|
||||
g.setColor(Locomotive.getBodyColor());
|
||||
g.fillRect((int)_startPosX + 10, (int)_startPosY + 10, 10, 10);
|
||||
|
@ -1,28 +1,24 @@
|
||||
import java.awt.*;
|
||||
|
||||
public class ExtraWheelsDraw {
|
||||
private WheelsCount wheelsCount;
|
||||
private int wheelsNum;
|
||||
private WheelsCount wheelsCount = WheelsCount.Two;
|
||||
public void setWheelsNum(int num) {
|
||||
wheelsNum = num;
|
||||
switch (wheelsNum) {
|
||||
switch (num) {
|
||||
case 0: {
|
||||
wheelsCount = WheelsCount.Two;
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
wheelsCount = WheelsCount.Three;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
case 1: {
|
||||
wheelsCount = WheelsCount.Four;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
private final Color color;
|
||||
private Color color;
|
||||
|
||||
public ExtraWheelsDraw(int num, Color color) {
|
||||
public void Init(int num, Color color) {
|
||||
setWheelsNum(num);
|
||||
this.color = color;
|
||||
}
|
||||
@ -32,17 +28,16 @@ public class ExtraWheelsDraw {
|
||||
g.drawOval(startPosX, startPosY + 40, 10, 10);
|
||||
g.drawOval(startPosX + 90, startPosY + 40, 10, 10);
|
||||
switch (wheelsCount) {
|
||||
case Two: {
|
||||
break;
|
||||
case Four: {
|
||||
g.drawOval(startPosX + 70, startPosY + 40, 10, 10);
|
||||
}
|
||||
case Three: {
|
||||
g.drawOval(startPosX + 20, startPosY + 40, 10, 10);
|
||||
break;
|
||||
}
|
||||
case Four: {
|
||||
g.drawOval(startPosX + 20, startPosY + 40, 10, 10);
|
||||
g.drawOval(startPosX + 70, startPosY + 40, 10, 10);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user