it is to be...

This commit is contained in:
antoc0der 2023-11-27 10:54:49 +03:00
parent 1252238fc4
commit 968cc81bc8
4 changed files with 16 additions and 16 deletions

View File

@ -51,11 +51,11 @@ public class FormAirplaneCollection {
listBoxStorages= new JList<>(listBoxModel); listBoxStorages= new JList<>(listBoxModel);
scrollPane.setViewportView(listBoxStorages); scrollPane.setViewportView(listBoxStorages);
JButton delStorageButton = new JButton("Удалить набор"); JButton delStorageButton = new JButton("Удалить набор");
toolBox.setBounds(623,12, 227, 80); //toolBox.setBounds(623,12, 227, 80);
JFrame collectionFrame = new JFrame(); JFrame collectionFrame = new JFrame();
collectionFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); collectionFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
collectionFrame.setSize(880,497); collectionFrame.setSize(880,497);
//toolBox.setBounds(623, 12, 227, 426); toolBox.setBounds(623, 12, 227, 426);
canv.setBounds(12,12,pictureBoxWidth,pictureBoxHeight); canv.setBounds(12,12,pictureBoxWidth,pictureBoxHeight);
JButton addButton = new JButton("Добавить"); JButton addButton = new JButton("Добавить");
JButton removeButton = new JButton("Удалить"); JButton removeButton = new JButton("Удалить");
@ -116,7 +116,7 @@ public class FormAirplaneCollection {
if(listBoxStorages.getSelectedIndex() == -1) { if(listBoxStorages.getSelectedIndex() == -1) {
return; return;
} }
AirplaneGenericStorage<DrawningAirplane, DrawningObjectAirplane> _airplanes = _storage.Get(listBoxStorages.getSelectedValue()); AirplaneGenericCollection<DrawningAirplane, DrawningObjectAirplane> _airplanes = _storage.Get(listBoxStorages.getSelectedValue());
FormAirplaneWithRadar form = new FormAirplaneWithRadar(); FormAirplaneWithRadar form = new FormAirplaneWithRadar();
form.buttonSelect.addActionListener(new ActionListener() { form.buttonSelect.addActionListener(new ActionListener() {
@Override @Override
@ -147,7 +147,6 @@ public class FormAirplaneCollection {
} }
String tmp = airplaneNumb.getText(); String tmp = airplaneNumb.getText();
int numb; int numb;
try{ try{
numb = Integer.parseInt(tmp); numb = Integer.parseInt(tmp);
} }
@ -170,7 +169,7 @@ public class FormAirplaneCollection {
if(listBoxStorages.getSelectedIndex() == -1) { if(listBoxStorages.getSelectedIndex() == -1) {
return; return;
} }
AirplaneGenericStorage<DrawningAirplane, DrawningObjectAirplane> _airplanes = _storage.Get(listBoxStorages.getSelectedValue()); AirplaneGenericCollection<DrawningAirplane, DrawningObjectAirplane> _airplanes = _storage.Get(listBoxStorages.getSelectedValue());
if(_airplanes == null) { if(_airplanes == null) {
return; return;
} }

View File

@ -11,18 +11,19 @@ public class AirplaneTrashCollection <T extends DrawningAirplane>{
_queue = new ArrayDeque<>(); _queue = new ArrayDeque<>();
} }
public void Push(T monorail){ public void Push(T airplane){
_queue.add(monorail); _queue.add(airplane);
} }
public int GetSize(){ public int GetSize(){
return _queue.size(); return _queue.size();
} }
public void Pop(){ public DrawningAirplane Pop(){
if(_queue.size() ==0) if(_queue.size() ==0)
return; return null;
_queue.remove();
return _queue.remove();
} }
public T GetTop(){ public T GetTop(){

View File

@ -10,17 +10,17 @@ public class SetGeneric <T extends Object>{
_maxCount = count; _maxCount = count;
_places = new ArrayList<>(); _places = new ArrayList<>();
} }
public boolean Insert(T monorail){ public boolean Insert(T airplane){
if(_places.size() == _maxCount) if(_places.size() == _maxCount)
return false; return false;
Insert(monorail, 0); Insert(airplane, 0);
return true; return true;
} }
public boolean Insert(T monorail, int position){ public boolean Insert(T airplane, int position){
if (!(position >= 0 && position <= _places.size() && _places.size() < _maxCount)) if (!(position >= 0 && position <= _places.size() && _places.size() < _maxCount))
return false; return false;
_places.add(position, monorail); _places.add(position, airplane);
Count++; Count++;
return true; return true;
} }
@ -32,7 +32,7 @@ public class SetGeneric <T extends Object>{
return true; return true;
} }
public T Get(int position){ public T Get(int position){
if(!(position >= 0 && position < Count)) if(!(position >= 0 && position < _places.size()))
return null; return null;
return (T)_places.get(position); return (T)_places.get(position);
} }

View File

@ -14,6 +14,6 @@ import javax.swing.*;
public class Main { public class Main {
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
FormForHard form = new FormForHard(); FormAirplaneCollection form = new FormAirplaneCollection();
} }
} }