This commit is contained in:
VictoriaPresnyakova 2022-12-05 11:12:21 +04:00
parent 57b8cbca08
commit 78d063574e
6 changed files with 58 additions and 68 deletions

View File

@ -35,7 +35,7 @@ public class DrawningBoat extends JPanel {
OarsDraw = new DrawningSqareOars();
break;
case 2:
OarsDraw = new DrawningTriangleOars();
OarsDraw = new DrawningOvalOars();
break;
}
SetOars();

View File

@ -10,7 +10,7 @@ public class DrawningCatamaran extends DrawningBoat{
@Override
public void DrawTransport(Graphics g)
{
if (! (Boat instanceof EntityCatamaran Airbus))
if (! (Boat instanceof EntityCatamaran Catamaran))
{
return;
}
@ -22,29 +22,20 @@ public class DrawningCatamaran extends DrawningBoat{
super.DrawTransport(g);
_startPosX -= 10;
_startPosY -= 5;
if (Airbus.Sail)
int _catamaranWidth = 80;
int _catamaranHeight = 50;
if (Catamaran.Sail)
{
// TODO draw Sail
g.drawRect(_startPosX + 70, _startPosY + 50, 22, 16);
g.drawRect(_startPosX + 8, _startPosY + 18, 22, 16);
g.drawOval(_startPosX, _startPosY + 18, 16, 16);
g.drawOval(_startPosX + 62, _startPosY + 50, 16, 16);
g2d.setPaint(Airbus.DopColor);
g.fillRect(_startPosX + 70, _startPosY + 50, 22, 16);
g.fillOval(_startPosX + 84, _startPosY + 50, 16, 16);
g.fillOval(_startPosX + 24, _startPosY + 18, 16, 16);
g.fillRect(_startPosX + 8, _startPosY + 18, 22, 16);
g2d.setPaint(Color.BLACK);
g.fillOval(_startPosX, _startPosY + 18, 16, 16);
g.fillOval(_startPosX + 62, _startPosY + 50, 16, 16);
g2d.setPaint(Catamaran.DopColor);
int[] p_x = {(int)(_startPosX + _catamaranWidth * 2 / 4), (int)(_startPosX + _catamaranWidth), (int)(_startPosX + _catamaranWidth * 2 / 4)};
int[] p_y = {(int)_startPosY + 5, (int)(_startPosY + _catamaranHeight / 2), (int)(_startPosY + _catamaranHeight)};
g.fillPolygon(p_x, p_y, 3);
}
if (Airbus.Floats)
if (Catamaran.Floats)
{
// TODO draw Floats
g.drawLine(_startPosX + 70, _startPosY + 20, _startPosX + 70, _startPosY + 35);
g.drawLine(_startPosX + 70, _startPosY + 20, _startPosX + 90, _startPosY + 35);
g2d.setPaint(Catamaran.DopColor);
g.fillOval(_startPosX, _startPosY, (int)(_catamaranWidth / 2), (int)(_catamaranHeight / 2));
g.fillOval(_startPosX, 27 + _startPosY + (int)(_catamaranHeight / 2), (int)(_catamaranWidth / 2), (int)(_catamaranHeight / 2));
}
}

36
DrawningOvalOars.java Normal file
View File

@ -0,0 +1,36 @@
import java.awt.*;
public class DrawningOvalOars implements IDrawningOars{
private OarsCount _Oars;
@Override
public void SetOarsCount(int numOfOars) {
_Oars = OarsCount.GetOarsCount(numOfOars);
}
@Override
public void DrawOars(Graphics g, int _startPosX, int _startPosY) {
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.BLACK);
int numOfOars = 0;
switch (_Oars)
{
case One:
numOfOars = 1;
break;
case Two:
numOfOars = 2;
break;
case Three:
numOfOars = 3;
break;
}
for(int i = numOfOars; i >= 1; --i){
g2d.setColor(Color.CYAN);
g2d.fillOval(_startPosX + (15 * (i + 1)), _startPosY -15, 15, 15);
g2d.setColor(Color.BLACK);
g2d.drawOval(_startPosX + (15 * (i + 1)), _startPosY - 15, 15, 15);
}
}
}

View File

@ -9,25 +9,25 @@ public class DrawningSqareOars implements IDrawningOars{
public void DrawOars(Graphics g, int _startPosX, int _startPosY) {
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.BLACK);
int numOfIlluminator = 0;
int numOfOars = 0;
switch (_Oars)
{
case One:
numOfIlluminator = 10;
numOfOars = 1;
break;
case Two:
numOfIlluminator = 20;
numOfOars = 2;
break;
case Three:
numOfIlluminator = 30;
numOfOars = 3;
break;
}
//TODO change
for(int i = numOfIlluminator; i >= 1; --i){
for(int i = numOfOars; i >= 1; --i){
g2d.setColor(Color.CYAN);
g2d.fillRect(_startPosX + 105 - 3 * i, _startPosY + 35, 3, 3);
g2d.fillRect(_startPosX + (15 * (i + 1)), _startPosY -15, 15, 15);
g2d.setColor(Color.BLACK);
g2d.drawRect(_startPosX + 105 - 3 * i, _startPosY + 35, 3, 3);
g2d.drawRect(_startPosX + (15 * (i + 1)), _startPosY - 15, 15, 15);
}
}
}

View File

@ -1,37 +0,0 @@
import java.awt.*;
public class DrawningTriangleOars implements IDrawningOars{
private OarsCount _Oars;
@Override
public void SetOarsCount(int numOfOars) {
_Oars = OarsCount.GetOarsCount(numOfOars);
}
@Override
public void DrawOars(Graphics g, int _startPosX, int _startPosY) {
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.BLACK);
int numOfIlluminator = 0;
switch (_Oars)
{
case One:
numOfIlluminator = 10;
break;
case Two:
numOfIlluminator = 20;
break;
case Three:
numOfIlluminator = 30;
break;
}
// TODO change
for(int i = numOfIlluminator; i >= 1; --i){
g2d.setColor(Color.CYAN);
g2d.drawPolygon(new int[] {_startPosX + 105 - 3 * i, _startPosX + 102 - 3 * i, _startPosX + 108 - 3 * i}, new int[] {_startPosY + 35, _startPosY + 38, _startPosY + 38}, 3);
g2d.setColor(Color.BLACK);
g2d.fillPolygon(new int[] {_startPosX + 105 - 3 * i, _startPosX + 102 - 3 * i, _startPosX + 108 - 3 * i}, new int[] {_startPosY + 35, _startPosY + 38, _startPosY + 38}, 3);
}
}
}

View File

@ -38,7 +38,7 @@ public class FormBoat extends JFrame{
}
private void SetData(){
Random random = new Random();
_boat.SetPosition(random.nextInt(10, 100), random.nextInt(10, 100), PictureBox.getWidth(), PictureBox.getHeight());
_boat.SetPosition(random.nextInt(10, 100), random.nextInt(30, 100), PictureBox.getWidth(), PictureBox.getHeight());
JLabelSpeed.setText("орость: " + _boat.GetBoat().GetSpeed() + " ");
JLabelWeight.setText("Вес: " + _boat.GetBoat().GetWeight() + " ");
JLabelColor.setText(("Цвет: " + _boat.GetBoat().GetBodyColor() + " "));