PIbd-23. Yunusov N.N. Lab work 06 Hard #6
@ -53,8 +53,7 @@ public class BusesGenericCollection<T extends DrawingBus, U extends IMoveableObj
|
||||
g.setStroke(pen);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) {
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
|
||||
1; ++j) {
|
||||
g.drawLine(i * _placeSizeWidth, j *
|
||||
1; ++j) {g.drawLine(i * _placeSizeWidth, j *
|
||||
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
|
||||
_placeSizeHeight);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.Queue;
|
||||
public class BusesGenericStorage {
|
||||
final HashMap<String, BusesGenericCollection<DrawingBus, DrawingObjectBus>> _busStorages;
|
||||
public HashMap<String, BusesGenericCollection<DrawingBus, DrawingObjectBus>> _busStorages;
|
||||
private static final char _separatorForKeyValue = '|';
|
||||
private final char _separatorRecords = ';';
|
||||
private static final char _separatorForObject = ':';
|
||||
|
@ -67,9 +67,9 @@ public class ExtentionDrawingBus {
|
||||
if(!(bus instanceof EntityTrolleybus)){
|
||||
return str;
|
||||
}
|
||||
return String.format("%s%c%b%c%b%c%s%c", str, separatorForObject,
|
||||
return String.format("%s%c%b%c%b%c%s", str, separatorForObject,
|
||||
((EntityTrolleybus) bus).getRoga(), separatorForObject,
|
||||
((EntityTrolleybus) bus).getBattery(), separatorForObject,
|
||||
getName(((EntityTrolleybus) bus).getAdditionalColor()), separatorForObject);
|
||||
getName(((EntityTrolleybus) bus).getAdditionalColor()));
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,12 @@
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.StrokeBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Queue;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
import java.util.HashMap;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
public class FrameBusCollection extends JFrame {
|
||||
private BusesGenericStorage storage;
|
||||
@ -24,7 +15,7 @@ public class FrameBusCollection extends JFrame {
|
||||
JComponent pictureBoxCollection;
|
||||
TextField textFieldNumber;
|
||||
TextField textFieldStorageName;
|
||||
Queue<DrawingBus> queue = new ArrayDeque<>();
|
||||
Queue<DrawingBus> trashCollection = new ArrayDeque<>();
|
||||
|
||||
public FrameBusCollection() {
|
||||
super("Набор автобусов");
|
||||
@ -154,7 +145,7 @@ public class FrameBusCollection extends JFrame {
|
||||
if (obj == null)
|
||||
return;
|
||||
int pos = Integer.parseInt(textFieldNumber.getText());
|
||||
queue.add(obj.Get(pos));
|
||||
trashCollection.add(obj.Get(pos));
|
||||
if (obj.remove(pos)) {
|
||||
JOptionPane.showMessageDialog(this, "Объект удалён");
|
||||
pictureBoxCollection.repaint();
|
||||
@ -197,18 +188,18 @@ public class FrameBusCollection extends JFrame {
|
||||
private void buttonDeleteCollectionClick() {
|
||||
if (listBoxStorages.getSelectedIndex() == -1)
|
||||
return;
|
||||
storage.delSet(listBoxStorages.getSelectedValue(), queue);
|
||||
storage.delSet(listBoxStorages.getSelectedValue(), trashCollection);
|
||||
reloadObjects();
|
||||
}
|
||||
|
||||
private void buttonTrashClick() {
|
||||
if (queue.size() == 0)
|
||||
if (trashCollection.size() == 0)
|
||||
return;
|
||||
FrameTrolleybus frame;
|
||||
try {
|
||||
frame = new FrameTrolleybus();
|
||||
frame.ChangeTrolleybus(queue.peek());
|
||||
queue.remove();
|
||||
frame.ChangeTrolleybus(trashCollection.peek());
|
||||
trashCollection.remove();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user