M Winda/src/winda/gui/WindaView.java poprawiono animację
M Winda/src/winda/logic/AlgorytmGoraDol.java naprawiono algorytm M Winda/src/winda/logic/PasazerSort.java usunięto błąd podwójnego zwiększania iteratora j
This commit is contained in:
parent
34f526e708
commit
ddba9e63f5
@ -59,10 +59,6 @@ platform.active=default_platform
|
|||||||
run.classpath=\
|
run.classpath=\
|
||||||
${javac.classpath}:\
|
${javac.classpath}:\
|
||||||
${build.classes.dir}
|
${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=\
|
run.test.classpath=\
|
||||||
${javac.test.classpath}:\
|
${javac.test.classpath}:\
|
||||||
${build.test.classes.dir}
|
${build.test.classes.dir}
|
||||||
|
@ -102,9 +102,17 @@ public class WindaView extends FrameView{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupAnimation(){
|
private void setupAnimation(){
|
||||||
int []passangers = new int[this.floor_count];
|
int []passangers = new int[this.floor_count+1];
|
||||||
for(int i=0;i<this.floor_count;i++)
|
ArrayList<Pietro> temp = (ArrayList) this.w.GetTrasa();
|
||||||
passangers[i] = w.GetTrasa().get(i).pasazerowieWsiadający.size();
|
for(int i=0;i<temp.size();i++){
|
||||||
|
int floor = temp.get(i).numerPietra;
|
||||||
|
int tmp = passangers[floor];
|
||||||
|
System.out.println("iterator: "+i+"<"+temp.size());
|
||||||
|
System.out.println("pietra: "+floor+"<"+this.floor_count);
|
||||||
|
passangers[floor] = tmp+ temp.get(i).pasazerowieWsiadający.size();
|
||||||
|
}
|
||||||
|
/* for(int i=0;i<this.floor_count && i<w.GetTrasa().size();i++)
|
||||||
|
passangers[i] = w.GetTrasa().get(i).pasazerowieWsiadający.size();*/
|
||||||
|
|
||||||
this.em.setPassangersOnFloors(passangers);
|
this.em.setPassangersOnFloors(passangers);
|
||||||
|
|
||||||
@ -123,7 +131,7 @@ public class WindaView extends FrameView{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void drawAnimation(){
|
private void drawAnimation(){
|
||||||
this.em = new ElevatorMovement(12);
|
this.em = new ElevatorMovement(12+1);
|
||||||
this.scrollPane1.add(em.getElevatorAnimation());
|
this.scrollPane1.add(em.getElevatorAnimation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -772,8 +780,8 @@ public class WindaView extends FrameView{
|
|||||||
String ip = (String) jSpinner1.getValue().toString();
|
String ip = (String) jSpinner1.getValue().toString();
|
||||||
int iloscPieter = Integer.parseInt(ip);
|
int iloscPieter = Integer.parseInt(ip);
|
||||||
w.SetIloscPieter(iloscPieter);
|
w.SetIloscPieter(iloscPieter);
|
||||||
this.newAnimation(iloscPieter);
|
this.newAnimation(iloscPieter+1);
|
||||||
this.floor_count = iloscPieter;
|
this.floor_count = iloscPieter+1;
|
||||||
}//GEN-LAST:event_jSpinner1StateChanged
|
}//GEN-LAST:event_jSpinner1StateChanged
|
||||||
|
|
||||||
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
|
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
|
||||||
|
@ -22,16 +22,19 @@ public class AlgorytmGoraDol implements IAlgorytm {
|
|||||||
public AlgorytmGoraDol(){
|
public AlgorytmGoraDol(){
|
||||||
this.start_floor = 0;
|
this.start_floor = 0;
|
||||||
this.floor_count = 0;
|
this.floor_count = 0;
|
||||||
|
this.floors = new ArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlgorytmGoraDol(int floor_count){
|
public AlgorytmGoraDol(int floor_count){
|
||||||
this.start_floor = 0;
|
this.start_floor = 0;
|
||||||
this.floor_count = floor_count;
|
this.floor_count = floor_count;
|
||||||
|
this.floors = new ArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlgorytmGoraDol(int floor_count, int start_floor){
|
public AlgorytmGoraDol(int floor_count, int start_floor){
|
||||||
this.floor_count = floor_count;
|
this.floor_count = floor_count;
|
||||||
this.start_floor = start_floor;
|
this.start_floor = start_floor;
|
||||||
|
this.floors = new ArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStartFloor(int start_floor){
|
public void setStartFloor(int start_floor){
|
||||||
@ -43,10 +46,11 @@ public class AlgorytmGoraDol implements IAlgorytm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setFloorCount(int floor_count){
|
public void setFloorCount(int floor_count){
|
||||||
|
System.out.println("setFloorCount ("+floor_count+")");
|
||||||
this.floor_count = floor_count;
|
this.floor_count = floor_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFloorCount(int floor_count){
|
public int getFloorCount(){
|
||||||
return this.floor_count;
|
return this.floor_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,13 +59,17 @@ public class AlgorytmGoraDol implements IAlgorytm {
|
|||||||
ArrayList<Pietro> pietra = this.setupPietra();
|
ArrayList<Pietro> pietra = this.setupPietra();
|
||||||
while(this.pasazerowie.get(i).GetStart()<this.acctual_floor)
|
while(this.pasazerowie.get(i).GetStart()<this.acctual_floor)
|
||||||
i++;
|
i++;
|
||||||
while(i<this.pasazerowie.size())
|
while(i<this.pasazerowie.size()){
|
||||||
if( this.pasazerowie.get(i).GetStart()<this.pasazerowie.get(i).GetStop()){
|
if( 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).GetStart()).pasazerowieWsiadający.add(this.pasazerowie.get(i));
|
||||||
pietra.get(this.pasazerowie.get(i).GetStop()).pasazerowieWysiadajacy.add(this.pasazerowie.get(i));
|
pietra.get(this.pasazerowie.get(i).GetStop()).pasazerowieWysiadajacy.add(this.pasazerowie.get(i));
|
||||||
}
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
this.clearPietra(pietra);
|
this.clearPietra(pietra);
|
||||||
this.floors.addAll(pietra);
|
|
||||||
|
if(!pietra.isEmpty())
|
||||||
|
this.floors.addAll(pietra);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void goDown(){
|
private void goDown(){
|
||||||
@ -69,26 +77,29 @@ public class AlgorytmGoraDol implements IAlgorytm {
|
|||||||
ArrayList<Pietro> pietra = this.setupPietra();
|
ArrayList<Pietro> pietra = this.setupPietra();
|
||||||
while(this.pasazerowie.get(i).GetStart()<this.acctual_floor)
|
while(this.pasazerowie.get(i).GetStart()<this.acctual_floor)
|
||||||
i++;
|
i++;
|
||||||
while(i<this.pasazerowie.size())
|
while(i<this.pasazerowie.size()){
|
||||||
if( this.pasazerowie.get(i).GetStart()>this.pasazerowie.get(i).GetStop()){
|
if( 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).GetStart()).pasazerowieWsiadający.add(this.pasazerowie.get(i));
|
||||||
pietra.get(this.pasazerowie.get(i).GetStop()).pasazerowieWysiadajacy.add(this.pasazerowie.get(i));
|
pietra.get(this.pasazerowie.get(i).GetStop()).pasazerowieWysiadajacy.add(this.pasazerowie.get(i));
|
||||||
}
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
this.clearPietra(pietra);
|
this.clearPietra(pietra);
|
||||||
this.floors.addAll(pietra);
|
if(!pietra.isEmpty())
|
||||||
|
this.floors.addAll(pietra);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearPietra(ArrayList<Pietro> pietro){
|
private void clearPietra(ArrayList<Pietro> pietro){
|
||||||
Pietro tmp;
|
for(int i=pietro.size()-1;i >= 0;i--){
|
||||||
for(int i=0;i<pietro.size();i++){
|
if(pietro.get(i).pasazerowieWsiadający.isEmpty() && pietro.get(i).pasazerowieWysiadajacy.isEmpty())
|
||||||
tmp=pietro.get(i);
|
|
||||||
if(tmp.pasazerowieWsiadający.isEmpty() && tmp.pasazerowieWysiadajacy.isEmpty())
|
|
||||||
pietro.remove(i);
|
pietro.remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Pietro> setCourse(){
|
public List<Pietro> setCourse(){
|
||||||
PasazerSort sort = new PasazerSort(pasazerowie);
|
this.calculateFloors();
|
||||||
|
|
||||||
|
PasazerSort sort = new PasazerSort(this.pasazerowie);
|
||||||
sort.sortByStart();
|
sort.sortByStart();
|
||||||
this.acctual_floor = this.start_floor;
|
this.acctual_floor = this.start_floor;
|
||||||
|
|
||||||
@ -103,7 +114,20 @@ public class AlgorytmGoraDol implements IAlgorytm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void SetMaxPietro(int maxPietro) {
|
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;i<this.pasazerowie.size();i++){
|
||||||
|
if(this.pasazerowie.get(i).GetStart()>this.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<Pietro> setupPietra(){
|
private ArrayList<Pietro> setupPietra(){
|
||||||
|
@ -24,7 +24,7 @@ public class PasazerSort {
|
|||||||
for( i = 1+ (j = start);i<end;i++)
|
for( i = 1+ (j = start);i<end;i++)
|
||||||
if(this.array.get(i).GetStart()<this.array.get(start).GetStart()){
|
if(this.array.get(i).GetStart()<this.array.get(start).GetStart()){
|
||||||
Pasazer tmp = this.array.get(++j);
|
Pasazer tmp = this.array.get(++j);
|
||||||
this.array.set(++j, this.array.get(i));
|
this.array.set(j, this.array.get(i));
|
||||||
this.array.set(i, tmp);
|
this.array.set(i, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ public class PasazerSort {
|
|||||||
private void mksortByStart(int start, int end){
|
private void mksortByStart(int start, int end){
|
||||||
if( start < end ){
|
if( start < end ){
|
||||||
int tmp = this.splitByStart( start, end );
|
int tmp = this.splitByStart( start, end );
|
||||||
this.mksortByStart( start, tmp-1 );
|
this.mksortByStart( start, tmp );
|
||||||
this.mksortByStart( tmp+1, end );
|
this.mksortByStart( tmp+1, end );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user