コード例 #1
0
  /**
   * Détermine si la forme engendrée par les 3 cases représente un bateau correct ou non
   *
   * @param lc
   * @return
   */
  private boolean isBoatCorrect(LinkedList<Case> lc) {
    if (lc.size() != 3) return false;

    // Order the list
    LinkedList<Case> nlc = new LinkedList<Case>();
    for (Entry<String, Integer> en : this.matchKeys.entrySet())
      for (Case c : lc) if (c.getName().equals(en.getKey())) nlc.add(c);

    String firstCase = nlc.get(0).getName();
    String secondCase = nlc.get(1).getName();
    String thirdCase = nlc.get(2).getName();

    List<String[]> rows = new ArrayList<String[]>();
    rows.add(this.numbersRowTitles);
    rows.add(this.firstRowTitles);
    rows.add(this.secondRowTitles);
    rows.add(this.thirdRowTitles);

    for (int i = 0; i < rows.size(); i++) {
      if (getIndexOf(rows.get(i), firstCase) != -1)
        return this.checkRow(rows, i, firstCase, secondCase, thirdCase);
    }

    return false;
  }
コード例 #2
0
 private int setCase(int x, int y, Batiment bat, int taillex, int tailley) {
   int axe, xtemp, ytemp;
   Case cas;
   for (int i = 0; i < taillex; i++) {
     for (int j = 0; j < tailley; j++) {
       xtemp = (x + i);
       ytemp = (y + j) * this.nbCasesLignes;
       axe = xtemp + ytemp;
       cas = this.grille.get(axe);
       if (cas.getStatut() != 0) {
         return -1;
       }
     }
   }
   for (int i = 0; i < taillex; i++) {
     for (int j = 0; j < tailley; j++) {
       xtemp = (x + i);
       ytemp = (y + j) * this.nbCasesLignes;
       axe = xtemp + ytemp;
       cas = this.grille.get(axe);
       cas.setOccuper(bat);
     }
   }
   return 0;
 }
コード例 #3
0
 public Color getCaseColor(int x, int y) {
   int axe;
   y = y * this.nbCasesLignes;
   axe = y + x;
   Case cas = this.grille.get(axe);
   return cas.getColor();
 }
コード例 #4
0
ファイル: SwitchBlock.java プロジェクト: ramire01/freemarker
 public String getCanonicalForm() {
   StringBuilder buf = new StringBuilder("<#switch ");
   buf.append(testExpression.getCanonicalForm());
   buf.append(">");
   for (int i = 0; i < nestedElements.size(); i++) {
     Case cas = (Case) nestedElements.get(i);
     buf.append(cas.getCanonicalForm());
   }
   if (defaultCase != null) {
     buf.append(defaultCase.getCanonicalForm());
   }
   buf.append("</#switch>");
   return buf.toString();
 }
コード例 #5
0
 public void setLibre(int x, int y) {
   int axe, xtemp, ytemp;
   Case cas;
   xtemp = x;
   ytemp = y * this.nbCasesLignes;
   axe = xtemp + ytemp;
   cas = this.grille.get(axe);
   for (int i = 0; i < cas.getBatiment().getTailleX(); i++) {
     for (int j = 0; j < cas.getBatiment().getTailleY(); j++) {
       xtemp = (x + i);
       ytemp = (y + j) * this.nbCasesLignes;
       axe = xtemp + ytemp;
       cas = this.grille.get(axe);
       cas.setVide();
     }
   }
 }
コード例 #6
0
ファイル: TypeChecking.java プロジェクト: DavePearce/jkit
  protected void checkSwitch(Stmt.Switch sw) {
    checkExpression(sw.condition());

    Type condT = sw.condition().attribute(Type.class);

    if (!(condT instanceof Type.Int)) {
      ErrorHandler.handleTypeMismatch(
          new TypeMismatchException(sw.condition(), T_INT, loader, types),
          sw.condition().attribute(SourceLocation.class));
    }

    for (Case c : sw.cases()) {
      checkExpression(c.condition());
      for (Stmt s : c.statements()) {
        checkStatement(s);
      }
    }
  }