コード例 #1
0
 private String getTweetPadding(int tweetIdx) { // copiado do Utils.java
   int MaxNTweets = 10000;
   StringBuilder strBuild = new StringBuilder();
   int current = (int) Math.floor(Math.log10(tweetIdx)) + 1;
   int expected = (int) Math.floor(Math.log10(MaxNTweets));
   if (tweetIdx == 0) current = 1;
   for (int i = 0; i < (expected - current); i++) strBuild.append(0);
   strBuild.append(tweetIdx);
   return strBuild.toString();
 }
コード例 #2
0
ファイル: troll.java プロジェクト: padawin/troll-game
 public troll(int id, String nom, int att, int deg, int esq, int tailleEchiquier) {
   idTroll = id;
   nomTroll = nom;
   this.att = att;
   this.deg = deg;
   this.esq = esq;
   this.vie = 40 - (att + deg + esq);
   paRestants = 6;
   positionX = (int) Math.floor(Math.random() * (tailleEchiquier)) + 1;
   positionY = (int) Math.floor(Math.random() * (tailleEchiquier)) + 1;
   valeur = "" + nomTroll.charAt(0);
 }
コード例 #3
0
ファイル: troll.java プロジェクト: padawin/troll-game
  public int score_Des(int nbDes) {

    int score = 0;
    for (int i = 0; i < nbDes; i++) {
      score = score + (int) Math.floor(Math.random() * (3)) + 1;
    }
    return (score);
  }
コード例 #4
0
ファイル: troll.java プロジェクト: padawin/troll-game
 public boolean loi_reussite() {
   int proba = (int) Math.floor(Math.random() * (100)) + 1;
   if (proba <= 80) {
     System.out.println("Action REUSSIE ! (" + proba + " sur 80%)");
     return (true);
   } else {
     System.out.println("Action RATEE ! (" + proba + " sur 80%)");
     return (false);
   }
 }
コード例 #5
0
ファイル: ExportServlet.java プロジェクト: Bacaa14/Coursola
 private Integer getHours(Integer time) {
   return (int) Math.floor(time / 60);
 }
コード例 #6
0
ファイル: troll.java プロジェクト: padawin/troll-game
  // constructeur
  public troll(int numtroll, int tailleEchiquier, Menu menu) {

    try {
      this.menu = menu;
      paRestants = 6;
      System.out.println();
      idTroll = numtroll;
      System.out.print("Nom du troll " + numtroll + ": ");
      nomTroll = IO.lireChaine();
      int points = 40;
      // System.out.println("Vous allez maitenant definir les carac de votre troll (attaque, degats,
      // esquive, vie)");
      boolean ok = false;
      while (ok == false) {
        System.out.println();
        System.out.print(
            "Nombre de D3 d'attaque (Il reste " + points + " a repartir dans 4 carac) : ");
        att = IO.lireEntier();
        if (att > points - 3) {
          System.out.println("Impossible de mettre autant de points dans 1 seule carac !!");
        } else {
          points = points - att;
          ok = true;
        }
      }
      ok = false;
      while (ok == false) {
        System.out.println();
        System.out.print(
            "Nombre de D3 de degats (Il reste " + points + " a repartir dans 3 carac) : ");
        deg = IO.lireEntier();
        if (deg > points - 2) {
          System.out.println("Impossible de mettre autant de points dans 1 seule carac !!");
        } else {
          points = points - deg;
          ok = true;
        }
      }
      ok = false;
      while (ok == false) {
        System.out.println();
        System.out.print(
            "Nombre de D3 d'esquive (Il reste " + points + " a repartir dans 2 carac) : ");
        esq = IO.lireEntier();
        if (esq > points - 1) {
          System.out.println("Impossible de mettre autant de points dans 1 seule carac !!");
        } else {
          points = points - esq;
          ok = true;
        }
      }
      System.out.println();
      System.out.println("Points de vie : " + points + "*" + "10 = " + points * 10);
      vie = points * 10;
      positionX = (int) Math.floor(Math.random() * (tailleEchiquier)) + 1;
      positionY = (int) Math.floor(Math.random() * (tailleEchiquier)) + 1;
      System.out.println("Il apparaitra en X=" + positionX + " Y=" + positionY);
      stmt.executeUpdate("delete from troll where idTroll=" + idTroll);
      proc = conn.prepareCall("{call init_troll(?,?,?,?,?,?,?,?)}");
      proc.setInt(1, numtroll);
      proc.setString(2, nomTroll);
      proc.setInt(3, att);
      proc.setInt(4, deg);
      proc.setInt(5, esq);
      proc.setInt(6, vie);
      proc.setInt(7, positionX);
      proc.setInt(8, positionY);
      proc.executeUpdate();
      proc.close();
    } catch (SQLException E) {
      System.err.println("SQLException: " + E.getMessage());
      System.err.println("SQLState:     " + E.getSQLState());
    }
    valeur = "" + nomTroll.charAt(0);
  }