Exemple #1
0
  /** @param args the command line arguments */
  public static void main(String[] args) {
    ElevatorSystem elevatorSystem = new ElevatorSystem();
    ElevatorFactory factory = new ElevatorFactory(elevatorSystem);

    int floors = 0;
    for (int i = 0; i < args.length; i++) {
      String mode = args[i];
      if (mode.equals(GUI)) {
        i++;
        floors = Integer.parseInt(args[i]);

        Elevator ele = factory.createForGui(floors);
        elevatorSystem.addElevator(ele);
      }

      if (mode.equals(IOW_MOCK)) {
        Elevator ele = factory.createForHardwareMock();
        elevatorSystem.addElevator(ele);
      }

      if (mode.equals(IOW)) {
        IOWarriorConnector iowc = IOWarriorConnector.getInstance();
        if (iowc.getWarriorCount() > 0) {
          for (int j = 0; j < iowc.getWarriorCount(); j++) {
            Elevator ele = factory.createForIOWarrior(iowc.getHandle(j));
            elevatorSystem.addElevator(ele);
          }
        }
      }
    }

    final GUIMain f = new GUIMain(elevatorSystem);
    f.setPreferredSize(new Dimension(500, 900));
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    f.pack();
    f.setVisible(true);
    f.repaint();

    elevatorSystem.start();
  }