Esempio n. 1
0
 public void determineBMI(User user) {
   PreparedStatement ps;
   try {
     ps =
         getConnection()
             .prepareStatement(
                 " SELECT  w.weight, u.length, w.user_IDuser "
                     + " FROM    uber.user u, uber.weight w "
                     + " WHERE w.user_IDuser = ? "
                     + " AND w.weightdate = ( SELECT MAX(w.weightdate) FROM uber.weight w WHERE w.user_IDuser = ? )"
                     + " AND u.iduser = ? ");
     this.user = user;
     ps.setInt(1, user.getIdUser());
     ps.setInt(2, user.getIdUser());
     ps.setInt(3, user.getIdUser());
     ResultSet rs = ps.executeQuery();
     while (rs.next()) {
       height = rs.getDouble(2);
       weight = rs.getDouble(1);
     }
   } catch (SQLException e) {
     error("determineBMI()");
     e.printStackTrace();
   }
   BMICalculate();
 }
Esempio n. 2
0
  public void execute(Session bot, String channel, User user, String message)
      throws SessionException {
    SimpleStringTokenizer tokens = new SimpleStringTokenizer(message);
    List<SessionCommand> commandList = new LinkedList<SessionCommand>();
    SessionCommandManager manager = bot.getCommandManager();
    while (tokens.hasMoreTokens()) {
      SessionCommand command = manager.getCommand(tokens.nextToken());
      if (command != null) {
        commandList.add(command);
      }
    }
    if (commandList.size() < 1) {
      commandList = manager.getCommands();
    }

    String target = channel;
    if (commandList.size() > 1) {
      target = user.getNick();
    }
    for (SessionCommand t : commandList) {
      String msg;
      if (t.getUsage() == null) {
        msg = manager.getPrefix() + t.getName();
      } else {
        msg = manager.getPrefix() + t.getName() + " " + t.getUsage();
      }
      bot.msg(target, msg);
    }
  }
Esempio n. 3
0
 public void insertBMI(double bmiArg) {
   PreparedStatement ps;
   try {
     ps =
         getConnection()
             .prepareStatement("INSERT INTO uber.bmi (bmi, user_iduser) " + " VALUES (?, ?)");
     ps.setDouble(1, bmiArg);
     ps.setInt(2, user.getIdUser());
     ps.execute();
   } catch (SQLException e) {
     error("insertBMI()");
     e.printStackTrace();
   }
 }
Esempio n. 4
0
 public String getUsernameTitleToString() {
   return user.getUserName() + ": " + title;
 }
Esempio n. 5
0
 @Override
 public String toString() {
   return user.getUserName() + ": " + text;
 }