Esempio n. 1
0
  /** @param args the command line arguments */
  public static void main(String[] args) {
    Grid g = Grid.getInstance();
    System.out.println(g.toString());

    MainWindow mainWindow = new MainWindow();
    mainWindow.setVisible(true);
    mainWindow.drawGrid(g);
    System.out.println(g);
    mainWindow.setSpeed(Agent.getSpeed());
    g.startAgents();

    long start = System.currentTimeMillis();
    while (true) {
      if (System.currentTimeMillis() - start > 10) {
        int car = g.nbCarriedItem();
        int ongrid = g.nbItemsOnGrid();
        MainWindow.getInstance().drawGrid(g);

        mainWindow.setCarried(car);

        mainWindow.setOngrid(ongrid);

        mainWindow.setTotal(car + ongrid);

        start = System.currentTimeMillis();
      }
    }
  }
Esempio n. 2
0
  @Test
  public void setTest() {
    Grid<Integer> grid = new Grid<Integer>(4, 2, null);

    grid.set(0, 0, 1);
    grid.set(1, 0, 4);
    grid.set(3, 0, 3);

    System.out.println(grid.toString());

    assertEquals(3, (int) grid.get(3, 0));
    assertNull(grid.get(2, 0));
  }
 public static void main(String[] args) {
   Grid test = GridGenerator.genGrid();
   System.out.println(test.toString());
 }