Дополнительные требования 8-я лабораторная.
This commit is contained in:
parent
f1b87ec380
commit
a33cad132d
@ -12,3 +12,62 @@ INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningO
|
||||
INFO FormMapWithSetPlanesGeneric:193 - Осуществлён переход на карту под названием 123 04-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:193 - Осуществлён переход на карту под названием 123 04-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:193 - Осуществлён переход на карту под названием 123 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:193 - Осуществлён переход на карту под названием 123 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:243 - Не удалось добавить объект: DrawningObjectPlane@1eb949d8 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:243 - Не удалось добавить объект: DrawningObjectPlane@74fedff2 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:243 - Не удалось добавить объект: DrawningObjectPlane@3b9e2c78 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@4d752dd4 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:193 - Осуществлён переход на карту под названием 123 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:159 - Добавлена карта 123 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:193 - Осуществлён переход на карту под названием 123 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@11666d2d 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@14a9f7e3 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:159 - Добавлена карта 123 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:193 - Осуществлён переход на карту под названием 123 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@29ad0152 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:243 - Не удалось добавить объект: DrawningObjectPlane@12327490 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@275ec948 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@3f0f1833 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:243 - Не удалось добавить объект: DrawningObjectPlane@26150cea 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@4b0a84c9 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:243 - Не удалось добавить объект: DrawningObjectPlane@71c59f4b 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@6beecbeb 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:159 - Добавлена карта 123 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:193 - Осуществлён переход на карту под названием 123 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@6a6eb2c8 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@62700ec9 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@2b9a8ca9 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@62d26d5b 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@dfe4f60 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@2243f6ad 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@7382be23 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:243 - Не удалось добавить объект: DrawningObjectPlane@1ae56700 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@6ce250d0 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:296 - Oбъект удалён: DrawningObjectPlane@6a6eb2c8 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:296 - Oбъект удалён: DrawningObjectPlane@7382be23 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:296 - Oбъект удалён: DrawningObjectPlane@6ce250d0 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:296 - Oбъект удалён: DrawningObjectPlane@dfe4f60 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:296 - Oбъект удалён: DrawningObjectPlane@2243f6ad 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@20158819 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@cc4579c 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@538899df 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@2178dabf 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:159 - Добавлена карта 4 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:193 - Осуществлён переход на карту под названием 4 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@2ca7100c 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@61179e86 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:159 - Добавлена карта 123 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:193 - Осуществлён переход на карту под названием 123 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@35255326 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@2cd85533 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:159 - Добавлена карта 123 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:193 - Осуществлён переход на карту под названием 123 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@3bb17a6b 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:243 - Не удалось добавить объект: DrawningObjectPlane@7990c580 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@6b3ebf28 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@255b2450 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:243 - Не удалось добавить объект: DrawningObjectPlane@406c548c 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@507dea2a 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@354749cd 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@25e737a1 05-12-2022
|
||||
INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@7ac63c8b 05-12-2022
|
||||
|
@ -10,6 +10,9 @@ public class DrawingAirbus extends DrawingPlane
|
||||
super(speed, weight, corpusColor, countWindow, 70, 30);
|
||||
Plane = new EntityAirbus(speed, weight, corpusColor, addColor, addCompartment, addEngine);
|
||||
this.addColor = addColor;
|
||||
|
||||
fields = new Object[]{speed, weight, corpusColor, _airplaneWindow.getClass().getSimpleName(), countWindow,
|
||||
addCompartment, addCompartment};
|
||||
}
|
||||
|
||||
//Второй конструктор
|
||||
|
@ -4,7 +4,7 @@ import java.awt.Color;
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
|
||||
public class DrawingPlane extends JPanel
|
||||
public class DrawingPlane extends JPanel implements Iterable<Object>, Iterator<Object>
|
||||
{
|
||||
protected float _startPosX; //левая координата отрисовки
|
||||
protected float _startPosY; //верхняя координата отрисовки
|
||||
@ -16,6 +16,11 @@ public class DrawingPlane extends JPanel
|
||||
protected EntityPlane Plane; //класс-сущность
|
||||
public IAdditionalDrawingObject _airplaneWindow; //для дополнительной отрисовки
|
||||
|
||||
private int currentIndex = 0;
|
||||
protected Object[] fields;
|
||||
|
||||
public int _countWindows; //для сравнения при вставке
|
||||
|
||||
public void SetColor(Color color)
|
||||
{
|
||||
Plane = new EntityPlane(Plane.GetSpeed(), Plane.GetWeight(), color);
|
||||
@ -25,6 +30,7 @@ public class DrawingPlane extends JPanel
|
||||
{
|
||||
_airplaneWindow = window;
|
||||
_airplaneWindow.SetAddEnum(countWindow);
|
||||
_countWindows = countWindow;
|
||||
}
|
||||
|
||||
public EntityPlane GetPlane()
|
||||
@ -53,6 +59,7 @@ public class DrawingPlane extends JPanel
|
||||
}
|
||||
|
||||
_airplaneWindow.SetAddEnum(countWindow);
|
||||
fields = new Object[]{speed, weight, corpusColor, _airplaneWindow.getClass().getSimpleName(), countWindow};
|
||||
}
|
||||
|
||||
//кол-во иллюминаторов
|
||||
@ -73,6 +80,9 @@ public class DrawingPlane extends JPanel
|
||||
{
|
||||
Plane = plane;
|
||||
_airplaneWindow = countWindow;
|
||||
|
||||
fields = new Object[]{plane.GetSpeed(), plane.GetWeight(),
|
||||
plane.GetColor(), _airplaneWindow.getClass().getSimpleName(), _countWindows};
|
||||
}
|
||||
|
||||
//установка координат позиции самолёта
|
||||
@ -226,19 +236,19 @@ public class DrawingPlane extends JPanel
|
||||
{
|
||||
return new float[]{_startPosX, _startPosY, _startPosX + _airbusWidth, _startPosY + _airbusHeight};
|
||||
}
|
||||
/*
|
||||
|
||||
@Override
|
||||
public Iterator<Object> iterator() {
|
||||
return null;
|
||||
public Iterator iterator() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return false;
|
||||
return currentIndex < fields.length && fields[currentIndex] != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object next() {
|
||||
return null;
|
||||
}*/
|
||||
return fields[currentIndex++];
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import java.awt.*;
|
||||
import java.util.Objects;
|
||||
|
||||
public class DrawningObjectPlane implements IDrawningObject
|
||||
{
|
||||
@ -83,6 +84,12 @@ public class DrawningObjectPlane implements IDrawningObject
|
||||
var plane = _plane.Plane;
|
||||
var otherPlanePlane = otherPlane._plane.Plane;
|
||||
|
||||
|
||||
if(plane.getClass().getSimpleName() != otherPlanePlane.getClass().getSimpleName())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(plane.GetSpeed() != otherPlanePlane.GetSpeed())
|
||||
{
|
||||
return false;
|
||||
@ -98,7 +105,12 @@ public class DrawningObjectPlane implements IDrawningObject
|
||||
return false;
|
||||
}
|
||||
|
||||
if(plane.getClass().getSimpleName() != otherPlanePlane.getClass().getSimpleName())
|
||||
if(_plane._airplaneWindow.getClass().getSimpleName() != otherPlane._plane._airplaneWindow.getClass().getSimpleName())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(_plane._countWindows != otherPlane._plane._countWindows)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -2,9 +2,8 @@ import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.SortedSet;
|
||||
|
||||
public class MapWithSetPlanesGeneric <T extends IDrawningObject, U extends AbstractMap>
|
||||
public class MapWithSetPlanesGeneric <T extends IDrawningObject, U extends AbstractMap> implements Comparable<MapWithSetPlanesGeneric<T,U>>
|
||||
{
|
||||
//ширина окна отрисовки
|
||||
private final int _pictureWidth;
|
||||
@ -117,6 +116,25 @@ public class MapWithSetPlanesGeneric <T extends IDrawningObject, U extends Abstr
|
||||
_setPlanes.SortSet(comparer);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(MapWithSetPlanesGeneric<T, U> o) {
|
||||
if (o == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (this == o)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Integer temp1 = _setPlanes.Count();
|
||||
Integer temp2 = o._setPlanes.Count();
|
||||
|
||||
return temp1.compareTo(temp2);
|
||||
}
|
||||
|
||||
//"взламываем" набор, чтобы все элементы оказались в начале
|
||||
private void Shaking() throws StorageOverflowException, PlaneNotFoundException {
|
||||
int j = _setPlanes.Count() - 1;
|
||||
|
@ -30,6 +30,12 @@ public class SetPlanesGeneric<T extends Object> implements Iterable<T>
|
||||
|
||||
//добавление объекта в набор на конкретную позицию
|
||||
public int Insert(T plane, int position) throws StorageOverflowException {
|
||||
//проверка на наличие такого же объекта
|
||||
if(_places.contains(plane))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
//проверка на переполнение хранилища
|
||||
if(_maxCount == Count())
|
||||
{
|
||||
@ -51,7 +57,7 @@ public class SetPlanesGeneric<T extends Object> implements Iterable<T>
|
||||
public T Remove(int position) throws PlaneNotFoundException
|
||||
{
|
||||
// проверка позиции
|
||||
if (position >= _places.size() || position < 0)
|
||||
if (position >= Count() || position < 0)
|
||||
{
|
||||
throw new PlaneNotFoundException(position);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user