Lab5 pull request

This commit is contained in:
Yunusov_Niyaz 2023-12-09 11:03:38 +04:00
parent a5e9097d61
commit 9ccf11fee9
3 changed files with 25 additions and 35 deletions

View File

@ -23,7 +23,6 @@ public class DrawingBus {
public int getHeight() {
return busHeight;
}
public int doorsNumber;
private IDrawDoors drawingDoors;
public DrawingBus(int speed, double weight, Color bodyColor, int width, int height, int doorsNumber, int doorsType) {
if (width < busWidth || height < busHeight)
@ -136,11 +135,11 @@ public class DrawingBus {
graphics2D.drawRect(_startPosX + 196, _startPosY + 91, 10, 20);
}
public IMoveableObject GetMoveableObject() { return new DrawingObjectBus(this);}
public void setDrawingDoors(IDrawDoors obj){
drawingDoors = obj;
public void setDrawingDoors(IDrawDoors doors){
drawingDoors = doors;
}
public void setDoorsNum(int num){
drawingDoors.setNumber(num);
public void setDoorsNumber(int number){
drawingDoors.setNumber(number);
}
public void setBodyColor(Color color){
entityBus.bodyColor = color;

View File

@ -105,31 +105,23 @@ public class FrameBusCollection extends JFrame {
if(listBoxStorages.getSelectedIndex() == -1) {
return;
}
BusesGenericCollection<DrawingBus, DrawingObjectBus> drawingBus = storage.getCollection(listBoxStorages.getSelectedValue());
BusesGenericCollection<DrawingBus, DrawingObjectBus> drawingBuses = storage.getCollection(listBoxStorages.getSelectedValue());
FrameBusConfig frameBusConfig = new FrameBusConfig();
frameBusConfig.addButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (drawingBus.insert(frameBusConfig.drawingBus))
{
frameBusConfig.dispose();
frameBusConfig.drawingBus.pictureWidth = pictureBoxCollection.getWidth();
frameBusConfig.drawingBus.pictureHeight = pictureBoxCollection.getHeight();
JOptionPane.showMessageDialog(null, "Объект добавлен", "Информация", JOptionPane.INFORMATION_MESSAGE);
pictureBoxCollection.repaint();
}
else
{
JOptionPane.showMessageDialog(null, "Не удалось добавить объект", "Информация", JOptionPane.INFORMATION_MESSAGE);
}
}
});
frameBusConfig.cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
frameBusConfig.addButton.addActionListener(e -> {
if (drawingBuses.insert(frameBusConfig.drawingBus))
{
frameBusConfig.dispose();
frameBusConfig.drawingBus.pictureWidth = pictureBoxCollection.getWidth();
frameBusConfig.drawingBus.pictureHeight = pictureBoxCollection.getHeight();
JOptionPane.showMessageDialog(null, "Объект добавлен", "Информация", JOptionPane.INFORMATION_MESSAGE);
pictureBoxCollection.repaint();
}
else
{
JOptionPane.showMessageDialog(null, "Не удалось добавить объект", "Информация", JOptionPane.INFORMATION_MESSAGE);
}
});
frameBusConfig.cancelButton.addActionListener(e -> frameBusConfig.dispose());
}
private void buttonRemoveBusClick() {
if (listBoxStorages.getSelectedIndex() == -1)
@ -186,15 +178,14 @@ public class FrameBusCollection extends JFrame {
private void buttonTrashClick(){
if(queue.size() == 0)
return;
FrameTrolleybus form;
FrameTrolleybus frame;
try{
form = new FrameTrolleybus();
form.ChangeTrolleybus(queue.peek());
frame = new FrameTrolleybus();
frame.ChangeTrolleybus(queue.peek());
queue.remove();
}
catch (IOException e){
throw new RuntimeException();
}
}
}

View File

@ -236,18 +236,18 @@ public class FrameBusConfig extends JFrame {
try {
int speed = ((Number) speedSpinner.getValue()).intValue();
int weight = ((Number) weightSpinner.getValue()).intValue();
int blocksNumber = ((Number) doorsNumberSpinner.getValue()).intValue();
int doorsNumber = ((Number) doorsNumberSpinner.getValue()).intValue();
switch ((String) support.getTransferable().getTransferData(DataFlavor.stringFlavor)) {
case "Простой" -> {
drawingBus = new DrawingBus(speed, weight, Color.WHITE,
pictureBoxWidth, pictureBoxHeight, 0, blocksNumber);
drawingBus.setDoorsNum(blocksNumber);
pictureBoxWidth, pictureBoxHeight, 0, doorsNumber);
drawingBus.setDoorsNumber(doorsNumber);
}
case "Продвинутый" -> {
drawingBus = new DrawingTrolleybus(speed, weight, Color.WHITE, Color.BLACK,
checkBoxRoga.isSelected(), checkBoxBattery.isSelected(),
pictureBoxWidth, pictureBoxHeight, 0, blocksNumber);
drawingBus.setDoorsNum(blocksNumber);
pictureBoxWidth, pictureBoxHeight, 0, doorsNumber);
drawingBus.setDoorsNumber(doorsNumber);
}
}
drawingBus.setPosition(pictureBoxWidth / 2 - drawingBus.getWidth() / 2,