diff --git a/Winda/src/winda/gui/WindaView.java b/Winda/src/winda/gui/WindaView.java index 876794a..8a2f9eb 100644 --- a/Winda/src/winda/gui/WindaView.java +++ b/Winda/src/winda/gui/WindaView.java @@ -101,6 +101,8 @@ public class WindaView extends FrameView{ t.start(); this.drawAnimation(); this.setupDemoPassangersList(); + this.jCheckBox2.setVisible(false); + this.jButton4.setVisible(false); } private void setupDemoPassangersList(){ @@ -157,6 +159,8 @@ public class WindaView extends FrameView{ private void goToPieto(){ this.em.setPietro((ArrayList) this.w.GetTrasa(), 1); + if (this.jCheckBox2.isSelected()) + this.em.setPietro((ArrayList) this.w.GetTrasaDwa(), 2); this.em.setEnterExitTime(czasWeWy); Thread t = new Thread(em); t.start(); @@ -963,10 +967,13 @@ public class WindaView extends FrameView{ }//GEN-LAST:event_jMenuItem3ActionPerformed private void jCheckBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox2ActionPerformed - if(jCheckBox2.isSelected()) + if(jCheckBox2.isSelected()) { this.em.enableSecondElevator(); - else + this.w.SetDwieWindy(); + } else { this.em.disableSecondElevator(); + this.w.SetJednaWindy(); + } this.newAnimation(this.floor_count); }//GEN-LAST:event_jCheckBox2ActionPerformed diff --git a/Winda/src/winda/logic/Winda.java b/Winda/src/winda/logic/Winda.java index 1097c9a..5a83eaf 100644 --- a/Winda/src/winda/logic/Winda.java +++ b/Winda/src/winda/logic/Winda.java @@ -25,6 +25,8 @@ public class Winda { private List pasazerowieCollection = new ArrayList(); private Parser parser = new Parser(); private List Trasa; + private List TrasaDwa; + private boolean DwieWindy = false; private Logger log; public Winda(){ @@ -42,6 +44,14 @@ public class Winda { this.CzasJazdyPietro = czas; } + public void SetDwieWindy (){ + this.DwieWindy = true; + } + + public void SetJednaWindy (){ + this.DwieWindy = false; + } + public void SetCzasWeWyOsoby(double czas){ this.CzasWeWyOsoby = czas; } @@ -84,6 +94,10 @@ public class Winda { return this.Trasa; } + public List GetTrasaDwa(){ + return this.TrasaDwa; + } + public void ZapiszPasazerow(String filename){ parser.Zapisz(filename, getPasazerowieCollection()); } @@ -101,7 +115,13 @@ public class Winda { public void Start(){ AlgorytmWindy.SetMaxPietro(IloscPieter); Trasa.clear(); - Trasa = AlgorytmWindy.Trasa(getPasazerowieCollection()); + if (DwieWindy){ + List> trasy = AlgorytmWindy.TrasaDwieWindy(pasazerowieCollection); + this.Trasa = trasy.get(0); + this.TrasaDwa = trasy.get(1); + } else { + Trasa = AlgorytmWindy.Trasa(getPasazerowieCollection()); + } CzasJazdy = Trasa.size()*CzasJazdyPietro+IloscPasazerow*CzasWeWyOsoby*2; CzasSredniObslugi = CzasJazdy / IloscPasazerow; CzasPietra = CzasJazdy / IloscPieter;