PIbd-22. Bulatova K.R. LabWork_01 HARD #1

Closed
bulatova_karina wants to merge 4 commits from LabWork_01 into master
14 changed files with 522 additions and 7 deletions

1
.idea/.name Normal file
View File

@ -0,0 +1 @@
Main.java

124
.idea/uiDesigner.xml Normal file
View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

View File

@ -1,12 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="1966194d-7a0e-41b7-8248-e72d6d03a650" name="Changes" comment="" />
<list default="true" id="1966194d-7a0e-41b7-8248-e72d6d03a650" name="Changes" comment="full 1 laba">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Enum" />
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
@ -16,12 +29,17 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;
}
}]]></component>
}</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="C:\Users\midni\IdeaProjects\WarmlyShip_HARD\src" />
</key>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
@ -31,6 +49,33 @@
<option name="presentableId" value="Default" />
<updated>1700585370664</updated>
</task>
<task id="LOCAL-00001" summary="Создание проекта">
<created>1700585393019</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1700585393019</updated>
</task>
<task id="LOCAL-00002" summary="full 1 laba">
<created>1702066529328</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1702066529328</updated>
</task>
<task id="LOCAL-00003" summary="full 1 laba">
<created>1703363710479</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1703363710479</updated>
</task>
<option name="localTasksCounter" value="4" />
<servers />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="Создание проекта" />
<MESSAGE value="full 1 laba" />
<option name="LAST_COMMIT_MESSAGE" value="full 1 laba" />
</component>
</project>

BIN
resources/down-arrow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

BIN
resources/left-arrow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

BIN
resources/right-arrow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 B

BIN
resources/upper-arrow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

5
src/CountDecks.java Normal file
View File

@ -0,0 +1,5 @@
public enum CountDecks {
OneDeck,
TwoDecks,
ThreeDecks
}

6
src/Direction.java Normal file
View File

@ -0,0 +1,6 @@
public enum Direction {
Up,
Down,
Left,
Right
}

41
src/DrawingDecks.java Normal file
View File

@ -0,0 +1,41 @@
import java.awt.*;
public class DrawingDecks {
private CountDecks countDecks;
private int NumberDecks;
public void SetCountDecks(int value){
NumberDecks = value;
switch (value){
case 2:
countDecks = CountDecks.TwoDecks;
break;
case 3:
countDecks = CountDecks.ThreeDecks;
break;
default:
countDecks = CountDecks.OneDeck;
}
};
public void DrawDeck(int x, int y, int width, int heght, Graphics g, Color BodyColor){
g.setColor(BodyColor);
g.fillRect(x, y, width, heght);
g.setColor(Color.black);
g.drawRect(x, y, width, heght);
}
public void DrawingDecks(int _startPosX, int _startPosY, Color BodyColor, Graphics g){
switch (countDecks){
case OneDeck:
DrawDeck(_startPosX + 25, _startPosY + 80, 130, 30, g, BodyColor);
break;
case TwoDecks:
DrawDeck(_startPosX + 25, _startPosY + 80, 130, 30, g, BodyColor);
Review

Имеется дублирующийся код

Имеется дублирующийся код
DrawDeck(_startPosX + 40, _startPosY + 55, 100, 25, g, BodyColor);
break;
case ThreeDecks:
DrawDeck(_startPosX + 25, _startPosY + 80, 130, 30, g, BodyColor);
Review

Имеется дублирующийся код

Имеется дублирующийся код
DrawDeck(_startPosX + 40, _startPosY + 55, 100, 25, g, BodyColor);
DrawDeck(_startPosX + 45, _startPosY + 30, 75, 25, g, BodyColor);
break;
}
}
}

120
src/DrawingShip.java Normal file
View File

@ -0,0 +1,120 @@
import java.awt.*;
public class DrawingShip {
private EntityShip entityShip;
public EntityShip GetEntityShip(){
return entityShip;
}
private void SetEntityShip(EntityShip entityShip){
this.entityShip = entityShip;
}
private DrawingDecks drawingDecks;
public DrawingDecks GetDrawingDecks(){
return drawingDecks;
}
private void SetDrawingDecks( DrawingDecks drawingDecks){
this.drawingDecks = drawingDecks;
}
private int _pictureWidth;
private int _pictureHeight;
private int _startPosX;
private int _startPosY;
private final int _shipWidth = 185;
private final int _shipHeight = 180;
public boolean Init(int speed, double weight, Color bodyColor, Color addColor, boolean pipes, boolean section, int width, int height, int countDecks){
if (width < _shipWidth || height <_shipHeight){
return false;
}
_pictureWidth = width;
_pictureHeight = height;
entityShip = new EntityShip();
entityShip.Init(speed, weight, bodyColor, addColor, pipes, section);
drawingDecks = new DrawingDecks();
drawingDecks.SetCountDecks(countDecks);
return true;
}
public void SetPosition(int x, int y){
if (x < 0 || x + _shipWidth > _pictureWidth){
x = 20;
}
if (y < 0 || y + _shipHeight > _pictureHeight){
y = 20;
}
_startPosX = x;
_startPosY = y;
}
public void MoveTransport(Direction direction){
if (entityShip == null){
return;
}
switch (direction){
case Left:
System.out.println(_startPosX + " " + entityShip.GetStep() + " " + _shipWidth + " " + (_startPosX + entityShip.GetStep() + _shipWidth) + " " + _pictureWidth);
if (_startPosX - entityShip.GetStep() > 0){
_startPosX -= (int)entityShip.GetStep();
}
break;
case Up:
System.out.println(_startPosY + " " + entityShip.GetStep() + " " + (_startPosY + entityShip.GetStep()) + " " + _pictureHeight);
if (_startPosY - entityShip.GetStep() > 0){
_startPosY -= (int)entityShip.GetStep();
}
break;
case Right:
System.out.println(_startPosX + " " + entityShip.GetStep() + " " + _shipWidth + " " + (_startPosX + entityShip.GetStep() + _shipWidth) + " " + _pictureWidth);
if (_startPosX + entityShip.GetStep() + _shipWidth < _pictureWidth){
_startPosX += (int)entityShip.GetStep();
}
break;
case Down:
System.out.println(_startPosY + " " + entityShip.GetStep() + " " + (_startPosY + entityShip.GetStep()) + " " + _pictureHeight);
if (_startPosY + entityShip.GetStep() + _shipHeight < _pictureHeight){
_startPosY += (int)entityShip.GetStep();
}
break;
}
}
public void DrawTransport(Graphics g) {
if (entityShip == null || drawingDecks == null) {
System.out.println("Error");
return;
}
//корпус
int[] XPoints = {_startPosX, _startPosX + 180, _startPosX + 140, _startPosX + 40, _startPosX};
int[] YPoints = {_startPosY + 110, _startPosY + 110, _startPosY + 185, _startPosY + 185, _startPosY + 110};
int nPoints = 5;
g.setColor(entityShip.GetBodyColor());
g.fillPolygon(XPoints, YPoints, nPoints);
g.setColor(Color.black);
g.drawPolygon(XPoints, YPoints, nPoints);
//якорь
g.drawLine(_startPosX + 50, _startPosY + 130, _startPosX + 50, _startPosY + 150);
g.drawLine(_startPosX + 40, _startPosY + 140, _startPosX + 60, _startPosY + 140);
g.drawLine(_startPosX + 45, _startPosY + 150, _startPosX + 55, _startPosY + 150);
//трубы
if (entityShip.GetPipes()) {
g.setColor(entityShip.GetAddColor());
g.fillRect(_startPosX + 55, _startPosY, 25, 80);
g.fillRect(_startPosX + 90, _startPosY + 20, 25, 60);
g.setColor(Color.black);
g.drawRect(_startPosX + 55, _startPosY, 25, 80);
g.drawRect(_startPosX + 90, _startPosY + 20, 25, 60);
}
//топливный отсек
if (entityShip.GetSection()) {
g.setColor(Color.gray);
g.fillOval(_startPosX + 130, _startPosY + 130, 20, 20);
g.setColor(Color.black);
g.drawOval(_startPosX + 130, _startPosY + 130, 20, 20);
}
//палуба
drawingDecks.DrawingDecks(_startPosX, _startPosY, entityShip.GetBodyColor(), g);
}
}

57
src/EntityShip.java Normal file
View File

@ -0,0 +1,57 @@
import java.awt.*;
public class EntityShip {
private int Speed;
public int GetSpeed(){
return Speed;
}
private void SetSpeed(int speed){
Speed = speed;
}
private double Weight;
public double GetWeight(){
return Weight;
}
private void SetWeight(int weight){
Weight = weight;
}
private Color BodyColor;
public Color GetBodyColor(){
return BodyColor;
}
private void SetBodyColor(Color bodyColor){
BodyColor = bodyColor;
}
private Color AdditionlaColor;
public Color GetAddColor(){
return AdditionlaColor;
}
private void SetAddColor(Color addColor){
AdditionlaColor = addColor;
}
private boolean Pipes;
public boolean GetPipes(){
return Pipes;
}
private void SetPipes(boolean pipes){
Pipes = pipes;
}
private boolean Section;
public boolean GetSection(){
return Section;
}
private void SetSection(boolean section){
Section = section;
}
private double Step;
public double GetStep() {
return (double)Speed * 100 / Weight;
}
public void Init(int speed, double weight, Color bodyColor, Color addColor, boolean pipes, boolean section){
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
AdditionlaColor = addColor;
Pipes = pipes;
Section = section;
}
}

116
src/FormWarmlyShip.java Normal file
View File

@ -0,0 +1,116 @@
import javax.swing.*;
import java.awt.*;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.*;
public class FormWarmlyShip{
private DrawingShip _drawingShip;
Canvas canv;
public void Draw(){
canv.repaint();
}
public FormWarmlyShip(){
JFrame frame = new JFrame("Warmly Ship");
JButton buttonCreate = new JButton("Создать");
buttonCreate.setFocusPainted(false);
buttonCreate.setContentAreaFilled(false);
JButton buttonUp = new JButton();
buttonUp.setFocusPainted(false); //контур вокруг текста
buttonUp.setContentAreaFilled(false); //раскраска конпки
buttonUp.setName("up"); //имя кнопки при обработке нажания
buttonUp.setIcon(new ImageIcon(((new ImageIcon("resources/upper-arrow.png")).getImage()).getScaledInstance(35, 35, java.awt.Image.SCALE_SMOOTH)));
JButton buttonDown = new JButton();
buttonDown.setFocusPainted(false);
buttonDown.setContentAreaFilled(false);
buttonDown.setName("down");
buttonDown.setIcon(new ImageIcon(((new ImageIcon("resources/down-arrow.png")).getImage()).getScaledInstance(35, 35, java.awt.Image.SCALE_SMOOTH)));
JButton buttonLeft = new JButton();
buttonLeft.setFocusPainted(false);
buttonLeft.setContentAreaFilled(false);
buttonLeft.setName("left");
buttonLeft.setIcon(new ImageIcon(((new ImageIcon("resources/left-arrow.png")).getImage()).getScaledInstance(35, 35, java.awt.Image.SCALE_SMOOTH)));
JButton buttonRight = new JButton();
buttonRight.setFocusPainted(false);
buttonRight.setContentAreaFilled(false);
buttonRight.setName("right");
buttonRight.setIcon(new ImageIcon(((new ImageIcon("resources/right-arrow.png")).getImage()).getScaledInstance(35, 35, java.awt.Image.SCALE_SMOOTH)));
buttonCreate.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println(e.getActionCommand());
Random random = new Random();
_drawingShip = new DrawingShip();
_drawingShip.Init(
random.nextInt(200) + 100,
random.nextInt(2000) + 1000,
new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)),
new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)),
random.nextBoolean(), random.nextBoolean(), 900, 460, random.nextInt(3) + 1);
_drawingShip.SetPosition(random.nextInt(90) + 10, random.nextInt(90) + 10);
canv._drawingShip = _drawingShip;
Draw();
}
}
);
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println(((JButton)(e.getSource())).getName());
if (_drawingShip == null){
return;
}
switch ((((JButton)(e.getSource())).getName())){
case "up":
_drawingShip.MoveTransport(Direction.Up);
break;
case "down":
_drawingShip.MoveTransport(Direction.Down);
break;
case "left":
_drawingShip.MoveTransport(Direction.Left);
break;
case "right":
_drawingShip.MoveTransport(Direction.Right);
break;
}
Draw();
}
};
buttonUp.addActionListener(actionListener);
buttonDown.addActionListener(actionListener);
buttonLeft.addActionListener(actionListener);
buttonRight.addActionListener(actionListener);
frame.setSize(920, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(null);
canv = new Canvas();
canv.setBounds(0, 0, 900, 500);
buttonCreate.setBounds(10, 400, 100, 40);
buttonUp.setBounds(800, 360, 40, 40);
buttonDown.setBounds(800, 400, 40, 40);
buttonLeft.setBounds(760, 400, 40, 40);
buttonRight.setBounds(840, 400, 40, 40);
frame.add(canv);
frame.add(buttonCreate);
frame.add(buttonUp);
frame.add(buttonDown);
frame.add(buttonLeft);
frame.add(buttonRight);
frame.setVisible(true);
}
class Canvas extends JComponent{
public DrawingShip _drawingShip;
public Canvas(){}
public void paintComponent(Graphics g){
if (_drawingShip == null){
return;
}
super.paintComponents(g);
Graphics2D g2d = (Graphics2D)g;
_drawingShip.DrawTransport(g2d);
super.repaint();
}
}
}

View File

@ -1,5 +1,5 @@
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
new FormWarmlyShip();
}
}