Готовая Лабораторная 4

This commit is contained in:
Никита Белянин 2023-11-13 00:36:16 +04:00
parent 0667fc1a0a
commit 15fad249f5
4 changed files with 15 additions and 17 deletions

View File

@ -4,10 +4,11 @@ public class DrawingTank extends DrawingArmoVehicle {
protected IOrnamentForm OrnamentsForm; protected IOrnamentForm OrnamentsForm;
private boolean OrnamentAdd; private boolean OrnamentAdd;
// Конструктор (Инициализация характеристик)
public DrawingTank(int speed, double weight, Color bodyColor, int _numWheel, Color additionalColor, boolean bodyKit, boolean caterpillar, boolean tower, int width, int height, boolean ornamentAdd) { public DrawingTank(int speed, double weight, Color bodyColor, int _numWheel, Color additionalColor, boolean bodyKit, boolean caterpillar, boolean tower, int width, int height, boolean ornamentAdd) {
super(speed, weight, bodyColor, _numWheel, width, height); super(speed, weight, bodyColor, _numWheel, width, height);
ArmoVehicle = new EntityTank(speed, weight, bodyColor, _numWheel, additionalColor, bodyKit, caterpillar, tower); ArmoVehicle = new EntityTank(speed, weight, bodyColor, _numWheel, additionalColor, bodyKit, caterpillar, tower);
_TankWidth = ((EntityTank) ArmoVehicle).BodyKit ? 169 : 83; _TankWidth = ((EntityTank)ArmoVehicle).BodyKit ? 169 : 83;
this.OrnamentAdd = ornamentAdd; this.OrnamentAdd = ornamentAdd;
} }
@ -20,8 +21,8 @@ public class DrawingTank extends DrawingArmoVehicle {
} }
public void SetPosition(int x, int y) { public void SetPosition(int x, int y) {
_startPosX = Math.min(x, _pictureWidth - _TankWidth); _startPosX = Math.min(x, _pictureWidth-_TankWidth);
_startPosY = Math.min(y, _pictureHeight - _TankHeight); _startPosY = Math.min(y, _pictureHeight-_TankHeight);
} }
private boolean setOrnamentAdd() { private boolean setOrnamentAdd() {

View File

@ -158,8 +158,8 @@ public class FormTankCollection {
} }
); );
JButton toForm4GenericDopClass = new JButton("Генерация"); JButton toFormTankGenerate = new JButton("Генерация");
toForm4GenericDopClass.addActionListener( toFormTankGenerate.addActionListener(
new ActionListener() { new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
FormTankGenerate formTankGenerate = new FormTankGenerate(); FormTankGenerate formTankGenerate = new FormTankGenerate();
@ -214,7 +214,7 @@ public class FormTankCollection {
TextBoxNumber.setBounds(pictureBoxWidth - 10, 50, 170, 30); TextBoxNumber.setBounds(pictureBoxWidth - 10, 50, 170, 30);
ButtonRemoveTank.setBounds(pictureBoxWidth - 10, 90, 170, 30); ButtonRemoveTank.setBounds(pictureBoxWidth - 10, 90, 170, 30);
ButtonRefreshCollection.setBounds(pictureBoxWidth - 10, 130, 170, 30); ButtonRefreshCollection.setBounds(pictureBoxWidth - 10, 130, 170, 30);
toForm4GenericDopClass.setBounds(pictureBoxWidth - 10, 170, 170, 30); toFormTankGenerate.setBounds(pictureBoxWidth - 10, 170, 170, 30);
buttonAddSet.setBounds(pictureBoxWidth - 10, 210, 170, 20); buttonAddSet.setBounds(pictureBoxWidth - 10, 210, 170, 20);
textBoxSetName.setBounds(pictureBoxWidth - 10, 240, 170, 20); textBoxSetName.setBounds(pictureBoxWidth - 10, 240, 170, 20);
@ -228,15 +228,12 @@ public class FormTankCollection {
Frame.add(ButtonRemoveTank); Frame.add(ButtonRemoveTank);
Frame.add(ButtonRefreshCollection); Frame.add(ButtonRefreshCollection);
Frame.add(TextBoxNumber); Frame.add(TextBoxNumber);
Frame.add(toForm4GenericDopClass); Frame.add(toFormTankGenerate);
Frame.add(buttonAddSet); Frame.add(buttonAddSet);
Frame.add(textBoxSetName); Frame.add(textBoxSetName);
Frame.add(jListStorage); Frame.add(jListStorage);
Frame.add(buttonRemoveSet); Frame.add(buttonRemoveSet);
Frame.add(buttonGetRemoved); Frame.add(buttonGetRemoved);
Frame.setVisible(true); Frame.setVisible(true);
} }
} }

View File

@ -8,7 +8,7 @@ public class SetGeneric <T extends Object> {
// Максимальное количество объектов в списке // Максимальное количество объектов в списке
private final int _maxCount; private final int _maxCount;
// Конструктор // Конструктор
public SetGeneric(int count) { public SetGeneric(int count) {
_maxCount = count; _maxCount = count;
_places = new ArrayList<T>(count); _places = new ArrayList<T>(count);

View File

@ -3,7 +3,7 @@ import java.awt.image.BufferedImage;
public class TanksGenericCollections<T extends DrawingArmoVehicle, U extends IMoveableObject> { public class TanksGenericCollections<T extends DrawingArmoVehicle, U extends IMoveableObject> {
// Ширина и высота окна прорисовки // Высота и ширина окна прорисовки
private int _pictureWidth; private int _pictureWidth;
private int _pictureHeight; private int _pictureHeight;
@ -15,11 +15,11 @@ public class TanksGenericCollections<T extends DrawingArmoVehicle, U extends IMo
private SetGeneric<T> _collection; private SetGeneric<T> _collection;
// Конструтор // Конструтор
public TanksGenericCollections(int picWidth, int picHeight) { public TanksGenericCollections(int pictureWidth, int pictureHeight) {
int width = picWidth / _placeSizeWidth; int width = pictureWidth / _placeSizeWidth;
int height = picHeight / _placeSizeHeight; int height = pictureHeight / _placeSizeHeight;
_pictureWidth = picWidth; _pictureWidth = pictureWidth;
_pictureHeight = picHeight; _pictureHeight = pictureHeight;
_collection = new SetGeneric<T>(width * height); _collection = new SetGeneric<T>(width * height);
} }