Исправление: сортировка по ИнтерДоп
This commit is contained in:
parent
a0e946e6c2
commit
899cd39791
@ -37,6 +37,8 @@ public class ArmoredCarCompareByType implements Comparator<IDrawingObject> {
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (xCar.getArmoredCar().drawingCaterpillar.compareTo(yCar.getArmoredCar().drawingCaterpillar) != 0)
|
||||
return xCar.getArmoredCar().drawingCaterpillar.compareTo(yCar.getArmoredCar().drawingCaterpillar);
|
||||
var speedCompare = Integer.compare(xCar.getArmoredCar().getArmoredCar().getSpeed(), yCar.getArmoredCar().getArmoredCar().getSpeed());
|
||||
if (speedCompare != 0)
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
import java.awt.*;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class DrawingCaterpillar implements IDrawingCaterpillar {
|
||||
public class DrawingCaterpillar implements IDrawingCaterpillar, Comparable {
|
||||
private NumRinks numRinks = NumRinks.Four;
|
||||
private Color color;
|
||||
|
||||
@ -48,4 +49,15 @@ public class DrawingCaterpillar implements IDrawingCaterpillar {
|
||||
public NumRinks getNumRinks() {
|
||||
return numRinks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
if (!(o instanceof IDrawingCaterpillar))
|
||||
return -1;
|
||||
HashMap<String, Integer> dict = new HashMap<>();
|
||||
dict.put(DrawingCaterpillar.class.getName(), 0);
|
||||
dict.put(DrawingDoubleCaterpillar.class.getName(), 1);
|
||||
dict.put(DrawingCrossCaterpillar.class.getName(), 2);
|
||||
return Integer.compare(dict.get(this.getClass().getName()), dict.get(o.getClass().getName()));
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import java.awt.*;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class DrawingCrossCaterpillar implements IDrawingCaterpillar{
|
||||
private NumRinks numRinks = NumRinks.Four;
|
||||
@ -54,4 +55,15 @@ public class DrawingCrossCaterpillar implements IDrawingCaterpillar{
|
||||
public NumRinks getNumRinks() {
|
||||
return numRinks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
if (!(o instanceof IDrawingCaterpillar))
|
||||
return -1;
|
||||
HashMap<String, Integer> dict = new HashMap<>();
|
||||
dict.put(DrawingCaterpillar.class.getName(), 0);
|
||||
dict.put(DrawingDoubleCaterpillar.class.getName(), 1);
|
||||
dict.put(DrawingCrossCaterpillar.class.getName(), 2);
|
||||
return Integer.compare(dict.get(this.getClass().getName()), dict.get(o.getClass().getName()));
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import java.awt.*;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class DrawingDoubleCaterpillar implements IDrawingCaterpillar{
|
||||
private NumRinks numRinks = NumRinks.Four;
|
||||
@ -51,4 +52,15 @@ public class DrawingDoubleCaterpillar implements IDrawingCaterpillar{
|
||||
public NumRinks getNumRinks() {
|
||||
return numRinks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
if (!(o instanceof IDrawingCaterpillar))
|
||||
return -1;
|
||||
HashMap<String, Integer> dict = new HashMap<>();
|
||||
dict.put(DrawingCaterpillar.class.getName(), 0);
|
||||
dict.put(DrawingDoubleCaterpillar.class.getName(), 1);
|
||||
dict.put(DrawingCrossCaterpillar.class.getName(), 2);
|
||||
return Integer.compare(dict.get(this.getClass().getName()), dict.get(o.getClass().getName()));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import java.awt.*;
|
||||
|
||||
public interface IDrawingCaterpillar {
|
||||
public interface IDrawingCaterpillar extends Comparable{
|
||||
void setNumRinks(int n);
|
||||
|
||||
void DrawCaterpillar(Graphics2D g2d, int startPosX, int startPosY);
|
||||
|
Loading…
Reference in New Issue
Block a user