Mochalov D.V. Hard LabWork02 #2

Merged
eegov merged 14 commits from LabWork02 into LabWork01 2022-10-21 10:06:17 +04:00
4 changed files with 12 additions and 6 deletions
Showing only changes of commit 18a72916b6 - Show all commits

View File

@ -110,7 +110,7 @@ class DrawningLocomotive {
g.setColor(Color.BLACK);
g.drawRect( (int)_startPosX + 50, (int)_startPosY + 10, 10, 20);
//колеса
extraWheelsDraw.DrawWheels((int)_startPosX, (int)_startPosY, g);
extraWheelsDraw.DrawExtra((int)_startPosX, (int)_startPosY, g);
//движок
g.setColor(Locomotive.getBodyColor());
g.fillRect((int)_startPosX + 100, (int)_startPosY + 10, 10, 30);

View File

@ -23,7 +23,7 @@ public class DrawningWarmlyLocomotive extends DrawningLocomotive{
if (warmlyLocomotive.FuelStorage)
{
g.fillRect((int)_startPosX + 110, (int)_startPosY + 10, 10, 50);
g.fillRect((int)_startPosX + 120, (int)_startPosY + 10, 10, 50);
g.fillRect((int)_startPosX + 110, (int)_startPosY + 40, 20, 20);
g.fillRect((int)_startPosX + 110, (int)_startPosY, 30, 10);
}

View File

@ -1,8 +1,8 @@
import java.awt.*;
public class ExtraWheelsDraw {
public class ExtraWheelsDraw implements IDrawningExtra{
private WheelsCount wheelsCount = WheelsCount.Two;
public void setWheelsNum(int num) {
public void setExtraNum(int num) {
switch (num) {
case 0: {
wheelsCount = WheelsCount.Three;
@ -19,11 +19,11 @@ public class ExtraWheelsDraw {
private Color color;
public ExtraWheelsDraw(int num, Color color) {
setWheelsNum(num);
setExtraNum(num);
this.color = color;
}
public void DrawWheels(int startPosX, int startPosY, Graphics2D g) {
public void DrawExtra(int startPosX, int startPosY, Graphics2D g) {
g.setColor(color);
g.drawOval(startPosX, startPosY + 40, 10, 10);
g.drawOval(startPosX + 90, startPosY + 40, 10, 10);

6
IDrawningExtra.java Normal file
View File

@ -0,0 +1,6 @@
import java.awt.*;
public interface IDrawningExtra {
void setExtraNum(int num);
void DrawExtra(int startPosX, int startPosY, Graphics2D g);
}