public boolean insertPlayer(String email, String password, String name, int highscore) { Player p = new Player(); p.setEmail(email); p.setPassword(password); p.setName(name); p.setHighscore(highscore); try { em.persist(p); } catch (PersistenceException e) { return (false); } return true; }
public boolean updatePlayer(String email, String password, String name, int highscore) { Player player = findPlayer(email); if (player == null) return false; player.setPassword(password); player.setName(name); player.setHighscore(highscore); try { em.merge(player); } catch (IllegalArgumentException e) { return false; } return true; }