Лабораторная работа №3
This commit is contained in:
parent
4c5819779a
commit
7b7d2bb3a3
@ -5,36 +5,15 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="39e7c520-e505-4e53-a269-c949d7c9f5d1" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/AbstractCompany.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/AdditionalCollection.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/DepotSharingService.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/ICollectionGenericObjects.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/MassiveGenericObjects.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/Scripts/Forms/CanvasMonorail.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/Scripts/Wheels/IDrawingWheels.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjectMonorail/Scripts/DirectionType.class" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjectMonorail/Scripts/DrawingField.class" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjectMonorail/Scripts/DrawingModernMonorail.class" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjectMonorail/Scripts/DrawingMonorail$1.class" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjectMonorail/Scripts/DrawingMonorail.class" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjectMonorail/Scripts/EntityModernMonorail.class" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjectMonorail/Scripts/EntityMonorail.class" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjectMonorail/Scripts/FormModernMonorail$1.class" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjectMonorail/Scripts/FormModernMonorail.class" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjectMonorail/Scripts/MovementStratagy/AbstractStrategy.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjectMonorail/Scripts/MovementStratagy/AbstractStrategy.class" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjectMonorail/Scripts/MovementStratagy/IMoveableObject.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjectMonorail/Scripts/MovementStratagy/IMoveableObject.class" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjectMonorail/Scripts/MovementStratagy/MoveableMonorail.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjectMonorail/Scripts/MovementStratagy/MoveableMonorail.class" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/DirectionType.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Drawing/DirectionType.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/DrawingField.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Drawing/DrawingField.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/DrawingModernMonorail.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Drawing/DrawingModernMonorail.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/DrawingMonorail.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Drawing/DrawingMonorail.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/EntityModernMonorail.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Entities/EntityModernMonorail.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/EntityMonorail.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Entities/EntityMonorail.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/FormModernMonorail.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Forms/FormModernMonorail.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/MovementStratagy/AbstractStrategy.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/MovementStratagy/AbstractStrategy.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/MovementStratagy/IMoveableObject.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/MovementStratagy/IMoveableObject.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/MovementStratagy/MoveableMonorail.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/MovementStratagy/MoveableMonorail.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/Program.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Program.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjectMonorail/Scripts/Wheels/DrawingWheels.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjectMonorail/Scripts/Wheels/DrawingWheels.class" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/AdditionalCollection.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/AdditionalCollection.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/DepotSharingService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/DepotSharingService.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/Drawing/DrawingModernMonorail.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Drawing/DrawingModernMonorail.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/Drawing/DrawingMonorail.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Drawing/DrawingMonorail.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/Forms/FormAdditionalCollection.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Forms/FormAdditionalCollection.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/Forms/FormMonorailCollection.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Forms/FormMonorailCollection.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/Wheels/DrawingWheels.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Wheels/DrawingWheels.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@ -45,8 +24,8 @@
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="Interface" />
|
||||
<option value="Class" />
|
||||
<option value="Interface" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
@ -68,7 +47,8 @@
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"git-widget-placeholder": "LabWorking__3",
|
||||
"kotlin-language-version-configured": "true"
|
||||
"kotlin-language-version-configured": "true",
|
||||
"last_opened_file_path": "D:/Учеба/PIbd-11_Tarasov_V.D._Hard/ProjectMonorail"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="RunManager">
|
||||
@ -80,14 +60,6 @@
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
<component name="SharedIndexes">
|
||||
<attachedChunks>
|
||||
<set>
|
||||
<option value="jdk-21.0.2-openjdk-21.0.2-4caba194b151-4f524021" />
|
||||
<option value="jdk-22-openjdk-22-3183f394aec4-bad0321e" />
|
||||
</set>
|
||||
</attachedChunks>
|
||||
</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">
|
||||
|
Binary file not shown.
@ -5,10 +5,12 @@ import Scripts.Drawing.DrawingMonorail;
|
||||
import Scripts.Entities.EntityModernMonorail;
|
||||
import Scripts.Entities.EntityMonorail;
|
||||
import Scripts.Wheels.DrawingWheels;
|
||||
import Scripts.Wheels.IDrawingWheels;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Random;
|
||||
|
||||
public class AdditionalCollection <T extends EntityMonorail, U extends DrawingWheels>{
|
||||
public class AdditionalCollection <T extends EntityMonorail, U extends IDrawingWheels>{
|
||||
public T[] _collectionEntity;
|
||||
public U[] _collectionWheels;
|
||||
public AdditionalCollection(int size, Class<T> type1, Class<T> type2) {
|
||||
|
@ -36,7 +36,7 @@ public class DepotSharingService extends AbstractCompany {
|
||||
|
||||
int currnetIndex = 0;
|
||||
|
||||
for (int j = height - 1; j >= 0; j--) {
|
||||
for (int j = height; j >= 0; j--) {
|
||||
for (int i = 0; i < width; i++, currnetIndex++) {
|
||||
if (_collection.Get(currnetIndex) == null) continue;
|
||||
|
||||
|
@ -3,6 +3,7 @@ package Scripts.Drawing;
|
||||
import Scripts.Entities.EntityModernMonorail;
|
||||
import Scripts.Entities.EntityMonorail;
|
||||
import Scripts.Wheels.DrawingWheels;
|
||||
import Scripts.Wheels.IDrawingWheels;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Random;
|
||||
@ -19,7 +20,7 @@ public class DrawingModernMonorail extends DrawingMonorail {
|
||||
_wheelsSeed = rnd.nextInt(0, 2);
|
||||
}
|
||||
|
||||
public DrawingModernMonorail(EntityModernMonorail entityModernMonorail, DrawingWheels wheels)
|
||||
public DrawingModernMonorail(EntityModernMonorail entityModernMonorail, IDrawingWheels wheels)
|
||||
{
|
||||
super((EntityMonorail)entityModernMonorail, 190, 80, wheels);
|
||||
|
||||
|
@ -2,13 +2,14 @@ package Scripts.Drawing;
|
||||
|
||||
import Scripts.Entities.EntityMonorail;
|
||||
import Scripts.Wheels.DrawingWheels;
|
||||
import Scripts.Wheels.IDrawingWheels;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Random;
|
||||
|
||||
public class DrawingMonorail {
|
||||
protected EntityMonorail _entityMonorail;
|
||||
protected DrawingWheels _wheels;
|
||||
protected IDrawingWheels _wheels;
|
||||
|
||||
private Integer _pictureWidth = null;
|
||||
private Integer _pictureHeight = null;
|
||||
@ -20,7 +21,7 @@ public class DrawingMonorail {
|
||||
private int _drawningMonorailHeight = 80;
|
||||
|
||||
public EntityMonorail getMonorail() {return _entityMonorail;}
|
||||
public DrawingWheels getWheels() {return _wheels;}
|
||||
public IDrawingWheels getWheels() {return _wheels;}
|
||||
protected int _wheelsSeed;
|
||||
|
||||
public int GetPositionX() { return _startPositionX;}
|
||||
@ -53,7 +54,7 @@ public class DrawingMonorail {
|
||||
_wheelsSeed = rnd.nextInt(0, 2);
|
||||
}
|
||||
|
||||
public DrawingMonorail(EntityMonorail entityMonorail, Integer drawningMonorailWidth, Integer drawningMonorailHeight, DrawingWheels wheels)
|
||||
public DrawingMonorail(EntityMonorail entityMonorail, Integer drawningMonorailWidth, Integer drawningMonorailHeight, IDrawingWheels wheels)
|
||||
{
|
||||
this(drawningMonorailWidth, drawningMonorailHeight);
|
||||
|
||||
@ -67,7 +68,7 @@ public class DrawingMonorail {
|
||||
_wheelsSeed = rnd.nextInt(0, 2);
|
||||
}
|
||||
|
||||
public DrawingMonorail(EntityMonorail entityMonorail, DrawingWheels wheels)
|
||||
public DrawingMonorail(EntityMonorail entityMonorail, IDrawingWheels wheels)
|
||||
{
|
||||
this(100, 40);
|
||||
|
||||
|
@ -16,7 +16,7 @@ import java.util.Random;
|
||||
|
||||
public class FormAdditionalCollection extends JFrame {
|
||||
public DrawingMonorail _drawingMonorail = null;
|
||||
private DrawingMonorail copyMonorail = null;
|
||||
private DrawingMonorail _copyMonorail = null;
|
||||
private AbstractCompany _company = null;
|
||||
private CanvasMonorail _canvasMonorail = new CanvasMonorail();
|
||||
private AdditionalCollection<EntityMonorail, DrawingWheels> _additionalCollection = null;
|
||||
@ -35,8 +35,9 @@ public class FormAdditionalCollection extends JFrame {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(_drawingMonorail !=null){
|
||||
_company._collection.Insert(copyMonorail);
|
||||
_company._collection.Insert(_copyMonorail);
|
||||
FormMonorailCollection.canvasShow();
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -50,9 +51,9 @@ public class FormAdditionalCollection extends JFrame {
|
||||
_canvasMonorail._drawingMonorail = _drawingMonorail;
|
||||
_canvasMonorail.repaint();
|
||||
if (_drawingMonorail instanceof DrawingModernMonorail)
|
||||
copyMonorail = new DrawingModernMonorail((EntityModernMonorail) _drawingMonorail.getMonorail(), _drawingMonorail.getWheels());
|
||||
_copyMonorail = new DrawingModernMonorail((EntityModernMonorail) _drawingMonorail.getMonorail(), _drawingMonorail.getWheels());
|
||||
else
|
||||
copyMonorail = new DrawingMonorail(_drawingMonorail.getMonorail(), _drawingMonorail.getWheels());
|
||||
_copyMonorail = new DrawingMonorail(_drawingMonorail.getMonorail(), _drawingMonorail.getWheels());
|
||||
}
|
||||
});
|
||||
|
||||
@ -106,12 +107,9 @@ public class FormAdditionalCollection extends JFrame {
|
||||
random = new Random();
|
||||
EntityMonorail entity = _additionalCollection._collectionEntity[i];
|
||||
DrawingWheels drawingWheels = null;
|
||||
int numberOfEngines = ((int) ((Math.random() * 3) + 1) * 2);
|
||||
int typeOfEngines = (int) ((Math.random() * 3) + 1);
|
||||
if (entity instanceof EntityModernMonorail) {
|
||||
drawingWheels = new DrawingWheels();
|
||||
drawingWheels.SetCountWheels((int) ((Math.random() * 3) + 1) * 2);
|
||||
}
|
||||
drawingWheels = new DrawingWheels();
|
||||
drawingWheels.SetCountWheels((int) ((Math.random() * 3) + 1) * 2);
|
||||
|
||||
if(drawingWheels!=null){
|
||||
_additionalCollection.Insert(drawingWheels);
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ public class FormMonorailCollection extends JFrame{
|
||||
private Dimension dimension;
|
||||
public static CanvasFormMonorailCollection<DrawingMonorail> _canvasMonorail = new CanvasFormMonorailCollection<DrawingMonorail>();
|
||||
private static AbstractCompany _company = null;
|
||||
private JButton CreateButton = new JButton("Создать бомбардировщик");;
|
||||
private JButton CreateShipButton = new JButton("Создать базовый бомбардировщик");
|
||||
private JButton CreateButton = new JButton("Создать современный монорельс");;
|
||||
private JButton CreateShipButton = new JButton("Создать монорельс");
|
||||
private JButton RemoveButton = new JButton("Удалить");
|
||||
private JButton GoToCheckButton = new JButton("На проверку");
|
||||
private JButton RandomButton = new JButton("Случайные");
|
||||
@ -71,7 +71,6 @@ public class FormMonorailCollection extends JFrame{
|
||||
setMinimumSize(dimension);
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
|
||||
TextField = new JFormattedTextField();
|
||||
|
||||
ComboBoxCollections.addActionListener(new ActionListener() {
|
||||
|
@ -5,13 +5,16 @@ import Scripts.Wheels.CountWheels;
|
||||
import java.awt.*;
|
||||
import java.util.Random;
|
||||
|
||||
public class DrawingWheels {
|
||||
public class DrawingWheels implements IDrawingWheels{
|
||||
private CountWheels _wheels;
|
||||
private IOrnament _ornament;
|
||||
private int _seedOrnament;
|
||||
|
||||
public void SetCountWheels(int Count){
|
||||
for (CountWheels temp: CountWheels.values())
|
||||
if (temp.getCountWheels() == Count){
|
||||
Random rnd = new Random();
|
||||
_seedOrnament = rnd.nextInt(0, 3);
|
||||
_wheels=temp;
|
||||
return;
|
||||
}
|
||||
@ -26,9 +29,7 @@ public class DrawingWheels {
|
||||
}
|
||||
|
||||
public void DrawWheels(Graphics2D g,int startPosX[], int startPosY, Color color) {
|
||||
Random rnd = new Random();
|
||||
int ranOrnament = rnd.nextInt(0, 3);
|
||||
switch (ranOrnament) {
|
||||
switch (_seedOrnament) {
|
||||
case 0:
|
||||
_ornament = new DrawOrnament();
|
||||
break;
|
||||
|
9
ProjectMonorail/src/Scripts/Wheels/IDrawingWheels.java
Normal file
9
ProjectMonorail/src/Scripts/Wheels/IDrawingWheels.java
Normal file
@ -0,0 +1,9 @@
|
||||
package Scripts.Wheels;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public interface IDrawingWheels {
|
||||
public void SetCountWheels(int Count);
|
||||
public int getCountWheels();
|
||||
public void DrawWheels(Graphics2D g, int startPosX[], int startPosY, Color color);
|
||||
}
|
Loading…
Reference in New Issue
Block a user