Готовая лабораторная 3

This commit is contained in:
Никита Белянин 2023-11-12 22:05:13 +04:00
parent cb373bd4ed
commit 6a6597f3bf
3 changed files with 47 additions and 33 deletions

View File

@ -2,7 +2,7 @@ import java.awt.*;
public class DrawingStarOrnament implements IOrnamentForm { public class DrawingStarOrnament implements IOrnamentForm {
private CountWheels wheels; private CountWheels wheels;
private Color additionalColor; private Color StarColor;
public CountWheels getNumWheel() { public CountWheels getNumWheel() {
return wheels; return wheels;
} }
@ -25,9 +25,9 @@ public class DrawingStarOrnament implements IOrnamentForm {
} }
public void CaterpillarStar(Graphics g, int _startPosX, int _startPosY) { public void CaterpillarStar(Graphics g, int _startPosX, int _startPosY) {
additionalColor = Color.RED; StarColor = Color.RED;
g.setColor(additionalColor); g.setColor(StarColor);
int xPontsStar[] = {_startPosX + 15, _startPosX + 18, _startPosX + 21, _startPosX + 18, _startPosX + 19, _startPosX + 16, _startPosX + 12, _startPosX + 13, _startPosX + 12, _startPosX + 15, _startPosX + 16}; int xPontsStar[] = {_startPosX + 15, _startPosX + 18, _startPosX + 21, _startPosX + 18, _startPosX + 19, _startPosX + 16, _startPosX + 12, _startPosX + 12, _startPosX + 11, _startPosX + 15, _startPosX + 16};
int yPontsStar[] = {_startPosY + 35, _startPosY + 38, _startPosY + 38, _startPosY + 42, _startPosY + 45, _startPosY + 42, _startPosY + 45, _startPosY + 41, _startPosY + 38, _startPosY + 38, _startPosY + 35}; int yPontsStar[] = {_startPosY + 35, _startPosY + 38, _startPosY + 38, _startPosY + 42, _startPosY + 45, _startPosY + 42, _startPosY + 45, _startPosY + 41, _startPosY + 38, _startPosY + 38, _startPosY + 35};
g.drawPolygon(xPontsStar, yPontsStar, xPontsStar.length); g.drawPolygon(xPontsStar, yPontsStar, xPontsStar.length);
g.fillPolygon(xPontsStar, yPontsStar, xPontsStar.length); g.fillPolygon(xPontsStar, yPontsStar, xPontsStar.length);
@ -61,7 +61,6 @@ public class DrawingStarOrnament implements IOrnamentForm {
DrawWheels(g,_startPosX, _startPosY); DrawWheels(g,_startPosX, _startPosY);
DrawWheels(g,_startPosX + 25, _startPosY); DrawWheels(g,_startPosX + 25, _startPosY);
DrawWheels(g,_startPosX + 50, _startPosY); DrawWheels(g,_startPosX + 50, _startPosY);
DrawWheels(g,_startPosX + 75, _startPosY);
DrawWheels(g,_startPosX + 100, _startPosY); DrawWheels(g,_startPosX + 100, _startPosY);
CaterpillarStar(g,_startPosX + 5, _startPosY + 12); CaterpillarStar(g,_startPosX + 5, _startPosY + 12);

View File

@ -2,7 +2,7 @@ import java.awt.*;
public class DrawingSuspensionOrnament implements IOrnamentForm { public class DrawingSuspensionOrnament implements IOrnamentForm {
private CountWheels wheels; private CountWheels wheels;
private Color additionalColor; private Color SuspensionColor;
public CountWheels getNumWheel() { public CountWheels getNumWheel() {
return wheels; return wheels;
} }
@ -24,19 +24,24 @@ public class DrawingSuspensionOrnament implements IOrnamentForm {
} }
} }
public void DrawWheels(Graphics g, int _startPosX, int _startPosY){ public void DrawWheels(Graphics g, int _startPosX, int _startPosY) {
g.setColor(Color.BLACK); g.setColor(Color.BLACK);
g.fillOval(10 + _startPosX, 42 + _startPosY, 20, 20); g.fillOval(10 + _startPosX, 42 + _startPosY, 20, 20);
} }
public void DrawSuspension(Graphics g, int _startPosX, int _startPosY) {
SuspensionColor = Color.BLUE;
g.setColor(SuspensionColor);
g.fillRect(_startPosX + 27, _startPosY + 50, 10, 3);
}
public void Draw(Graphics g, int _startPosX, int _startPosY) { public void Draw(Graphics g, int _startPosX, int _startPosY) {
if (wheels == CountWheels.Two){ if (wheels == CountWheels.Two) {
DrawWheels(g,_startPosX, _startPosY); DrawWheels(g,_startPosX, _startPosY);
DrawWheels(g,_startPosX + 100, _startPosY); DrawWheels(g,_startPosX + 100, _startPosY);
additionalColor = Color.RED;
g.setColor(additionalColor); DrawSuspension(g, _startPosX, _startPosY);
g.fillRect(_startPosX + 27, _startPosY + 50, 10, 3); DrawSuspension(g,_startPosX + 73, _startPosY);
g.fillRect(_startPosX + 51, _startPosY + 50, 10, 3);
} }
if (wheels == CountWheels.Three) { if (wheels == CountWheels.Three) {
@ -44,9 +49,9 @@ public class DrawingSuspensionOrnament implements IOrnamentForm {
DrawWheels(g,_startPosX + 50, _startPosY); DrawWheels(g,_startPosX + 50, _startPosY);
DrawWheels(g,_startPosX + 100, _startPosY); DrawWheels(g,_startPosX + 100, _startPosY);
g.fillRect(_startPosX + 27, _startPosY + 50, 10, 3); DrawSuspension(g, _startPosX, _startPosY);
g.fillRect(_startPosX + 51, _startPosY + 50, 10, 3); DrawSuspension(g,_startPosX + 24, _startPosY);
g.fillRect(_startPosX + 80, _startPosY + 50, 10, 3); DrawSuspension(g,_startPosX + 73, _startPosY);
} }
if (wheels == CountWheels.Four) { if (wheels == CountWheels.Four) {
@ -56,10 +61,10 @@ public class DrawingSuspensionOrnament implements IOrnamentForm {
DrawWheels(g,_startPosX + 75, _startPosY); DrawWheels(g,_startPosX + 75, _startPosY);
DrawWheels(g,_startPosX + 100, _startPosY); DrawWheels(g,_startPosX + 100, _startPosY);
g.fillRect(_startPosX + 27, _startPosY + 50, 10, 3); DrawSuspension(g, _startPosX, _startPosY);
g.fillRect(_startPosX + 51, _startPosY + 50, 10, 3); DrawSuspension(g,_startPosX + 24, _startPosY);
g.fillRect(_startPosX + 80, _startPosY + 50, 10, 3); DrawSuspension(g,_startPosX + 53, _startPosY);
g.fillRect(_startPosX + 101, _startPosY + 50, 10, 3); DrawSuspension(g,_startPosX + 73, _startPosY);
} }
} }
} }

View File

@ -2,13 +2,13 @@ import java.awt.*;
public class DrawingWheelsCombination implements IOrnamentForm { public class DrawingWheelsCombination implements IOrnamentForm {
private CountWheels wheels; private CountWheels wheels;
private Color additionalColor; private Color CombinationColor;
public CountWheels getNumWheel() { public CountWheels getNumWheel() {
return wheels; return wheels;
} }
public void setDigit(int number) { public void setDigit(int number) {
switch(number){ switch(number) {
case 2: case 2:
wheels = CountWheels.Two; wheels = CountWheels.Two;
break; break;
@ -25,14 +25,20 @@ public class DrawingWheelsCombination implements IOrnamentForm {
} }
public void CaterpillarStar(Graphics g, int _startPosX, int _startPosY) { public void CaterpillarStar(Graphics g, int _startPosX, int _startPosY) {
additionalColor = Color.RED; CombinationColor = Color.RED;
g.setColor(additionalColor); g.setColor(CombinationColor);
int xPontsStar[] = {_startPosX + 15, _startPosX + 18, _startPosX + 21, _startPosX + 18, _startPosX + 19, _startPosX + 16, _startPosX + 12, _startPosX + 13, _startPosX + 12, _startPosX + 15, _startPosX + 16}; int xPontsStar[] = {_startPosX + 15, _startPosX + 18, _startPosX + 21, _startPosX + 18, _startPosX + 19, _startPosX + 16, _startPosX + 12, _startPosX + 13, _startPosX + 12, _startPosX + 15, _startPosX + 16};
int yPontsStar[] = {_startPosY + 35, _startPosY + 38, _startPosY + 38, _startPosY + 42, _startPosY + 45, _startPosY + 42, _startPosY + 45, _startPosY + 41, _startPosY + 38, _startPosY + 38, _startPosY + 35}; int yPontsStar[] = {_startPosY + 35, _startPosY + 38, _startPosY + 38, _startPosY + 42, _startPosY + 45, _startPosY + 42, _startPosY + 45, _startPosY + 41, _startPosY + 38, _startPosY + 38, _startPosY + 35};
g.drawPolygon(xPontsStar, yPontsStar, xPontsStar.length); g.drawPolygon(xPontsStar, yPontsStar, xPontsStar.length);
g.fillPolygon(xPontsStar, yPontsStar, xPontsStar.length); g.fillPolygon(xPontsStar, yPontsStar, xPontsStar.length);
} }
public void DrawSuspension(Graphics g, int _startPosX, int _startPosY) {
CombinationColor = Color.BLUE;
g.setColor(CombinationColor);
g.fillRect(_startPosX + 27, _startPosY + 50, 10, 3);
}
public void DrawWheels(Graphics g, int _startPosX, int _startPosY){ public void DrawWheels(Graphics g, int _startPosX, int _startPosY){
g.setColor(Color.BLACK); g.setColor(Color.BLACK);
g.fillOval(10 + _startPosX, 42 + _startPosY, 20, 20); g.fillOval(10 + _startPosX, 42 + _startPosY, 20, 20);
@ -43,8 +49,8 @@ public class DrawingWheelsCombination implements IOrnamentForm {
DrawWheels(g,_startPosX, _startPosY); DrawWheels(g,_startPosX, _startPosY);
DrawWheels(g,_startPosX + 100, _startPosY); DrawWheels(g,_startPosX + 100, _startPosY);
g.fillRect(_startPosX + 27, _startPosY + 50, 10, 3); DrawSuspension(g, _startPosX, _startPosY);
g.fillRect(_startPosX + 101, _startPosY + 50, 10, 3); DrawSuspension(g,_startPosX + 73, _startPosY);
CaterpillarStar(g,_startPosX + 5, _startPosY + 12); CaterpillarStar(g,_startPosX + 5, _startPosY + 12);
CaterpillarStar(g,_startPosX + 105, _startPosY + 12); CaterpillarStar(g,_startPosX + 105, _startPosY + 12);
@ -55,10 +61,9 @@ public class DrawingWheelsCombination implements IOrnamentForm {
DrawWheels(g,_startPosX + 50, _startPosY); DrawWheels(g,_startPosX + 50, _startPosY);
DrawWheels(g,_startPosX + 100, _startPosY); DrawWheels(g,_startPosX + 100, _startPosY);
g.fillRect(_startPosX + 27, _startPosY + 50, 10, 3); DrawSuspension(g, _startPosX, _startPosY);
g.fillRect(_startPosX + 51, _startPosY + 50, 10, 3); DrawSuspension(g,_startPosX + 24, _startPosY);
g.fillRect(_startPosX + 100, _startPosY + 50, 10, 3); DrawSuspension(g,_startPosX + 73, _startPosY);
CaterpillarStar(g,_startPosX + 5, _startPosY + 12); CaterpillarStar(g,_startPosX + 5, _startPosY + 12);
CaterpillarStar(g,_startPosX + 55, _startPosY + 12); CaterpillarStar(g,_startPosX + 55, _startPosY + 12);
@ -71,10 +76,10 @@ public class DrawingWheelsCombination implements IOrnamentForm {
DrawWheels(g,_startPosX + 50, _startPosY); DrawWheels(g,_startPosX + 50, _startPosY);
DrawWheels(g,_startPosX + 100, _startPosY); DrawWheels(g,_startPosX + 100, _startPosY);
g.fillRect(_startPosX + 27, _startPosY + 50, 10, 3); DrawSuspension(g, _startPosX, _startPosY);
g.fillRect(_startPosX + 51, _startPosY + 50, 10, 3); DrawSuspension(g,_startPosX + 24, _startPosY);
g.fillRect(_startPosX + 80, _startPosY + 50, 10, 3); DrawSuspension(g,_startPosX + 53, _startPosY);
g.fillRect(_startPosX + 101, _startPosY + 50, 10, 3); DrawSuspension(g,_startPosX + 73, _startPosY);
CaterpillarStar(g,_startPosX + 5, _startPosY + 12); CaterpillarStar(g,_startPosX + 5, _startPosY + 12);
CaterpillarStar(g,_startPosX + 30, _startPosY + 12); CaterpillarStar(g,_startPosX + 30, _startPosY + 12);
@ -89,6 +94,11 @@ public class DrawingWheelsCombination implements IOrnamentForm {
DrawWheels(g,_startPosX + 75, _startPosY); DrawWheels(g,_startPosX + 75, _startPosY);
DrawWheels(g,_startPosX + 100, _startPosY); DrawWheels(g,_startPosX + 100, _startPosY);
DrawSuspension(g, _startPosX, _startPosY);
DrawSuspension(g,_startPosX + 24, _startPosY);
DrawSuspension(g,_startPosX + 53, _startPosY);
DrawSuspension(g,_startPosX + 73, _startPosY);
CaterpillarStar(g,_startPosX + 5, _startPosY + 12); CaterpillarStar(g,_startPosX + 5, _startPosY + 12);
CaterpillarStar(g,_startPosX + 30, _startPosY + 12); CaterpillarStar(g,_startPosX + 30, _startPosY + 12);
CaterpillarStar(g,_startPosX + 55, _startPosY + 12); CaterpillarStar(g,_startPosX + 55, _startPosY + 12);