From ddba9e63f5350bf205df1fe04103d6c4d7ab10e3 Mon Sep 17 00:00:00 2001 From: Przemek Grondek Date: Wed, 20 Apr 2011 00:18:40 +0000 Subject: [PATCH] =?UTF-8?q?M=20=20=20=20Winda/src/winda/gui/WindaView.java?= =?UTF-8?q?=20poprawiono=20animacj=C4=99=20M=20=20=20=20Winda/src/winda/lo?= =?UTF-8?q?gic/AlgorytmGoraDol.java=20naprawiono=20algorytm=20M=20=20=20?= =?UTF-8?q?=20Winda/src/winda/logic/PasazerSort.java=20usuni=C4=99to=20b?= =?UTF-8?q?=C5=82=C4=85d=20podw=C3=B3jnego=20zwi=C4=99kszania=20iteratora?= =?UTF-8?q?=20j?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Winda/nbproject/project.properties | 4 -- Winda/src/winda/gui/WindaView.java | 20 +++++++--- Winda/src/winda/logic/AlgorytmGoraDol.java | 46 ++++++++++++++++------ Winda/src/winda/logic/PasazerSort.java | 4 +- 4 files changed, 51 insertions(+), 23 deletions(-) diff --git a/Winda/nbproject/project.properties b/Winda/nbproject/project.properties index eed2dea..4030c41 100644 --- a/Winda/nbproject/project.properties +++ b/Winda/nbproject/project.properties @@ -59,10 +59,6 @@ platform.active=default_platform run.classpath=\ ${javac.classpath}:\ ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs= run.test.classpath=\ ${javac.test.classpath}:\ ${build.test.classes.dir} diff --git a/Winda/src/winda/gui/WindaView.java b/Winda/src/winda/gui/WindaView.java index da8bc51..c22813c 100644 --- a/Winda/src/winda/gui/WindaView.java +++ b/Winda/src/winda/gui/WindaView.java @@ -102,9 +102,17 @@ public class WindaView extends FrameView{ } private void setupAnimation(){ - int []passangers = new int[this.floor_count]; - for(int i=0;i temp = (ArrayList) this.w.GetTrasa(); + for(int i=0;i pietra = this.setupPietra(); while(this.pasazerowie.get(i).GetStart() pietra = this.setupPietra(); while(this.pasazerowie.get(i).GetStart()this.pasazerowie.get(i).GetStop()){ pietra.get(this.pasazerowie.get(i).GetStart()).pasazerowieWsiadający.add(this.pasazerowie.get(i)); pietra.get(this.pasazerowie.get(i).GetStop()).pasazerowieWysiadajacy.add(this.pasazerowie.get(i)); } + i++; + } this.clearPietra(pietra); - this.floors.addAll(pietra); + if(!pietra.isEmpty()) + this.floors.addAll(pietra); } private void clearPietra(ArrayList pietro){ - Pietro tmp; - for(int i=0;i= 0;i--){ + if(pietro.get(i).pasazerowieWsiadający.isEmpty() && pietro.get(i).pasazerowieWysiadajacy.isEmpty()) pietro.remove(i); } } public List setCourse(){ - PasazerSort sort = new PasazerSort(pasazerowie); + this.calculateFloors(); + + PasazerSort sort = new PasazerSort(this.pasazerowie); sort.sortByStart(); this.acctual_floor = this.start_floor; @@ -103,7 +114,20 @@ public class AlgorytmGoraDol implements IAlgorytm { } public void SetMaxPietro(int maxPietro) { - this.setFloorCount(floor_count); + this.setFloorCount(floor_count+1); + } + + /* + * Fix for wrong number of floors + */ + private void calculateFloors(){ + for(int i=0;ithis.floor_count) + this.floor_count = this.pasazerowie.get(i).GetStart(); + if(this.pasazerowie.get(i).GetStop()>this.floor_count) + this.floor_count = this.pasazerowie.get(i).GetStop(); + } + this.floor_count++; } private ArrayList setupPietra(){ diff --git a/Winda/src/winda/logic/PasazerSort.java b/Winda/src/winda/logic/PasazerSort.java index b33ac11..bbe82a9 100644 --- a/Winda/src/winda/logic/PasazerSort.java +++ b/Winda/src/winda/logic/PasazerSort.java @@ -24,7 +24,7 @@ public class PasazerSort { for( i = 1+ (j = start);i