@Override
public User register(String firstName, String lastName, String email, String username, String password) throws CaprabankException {
if (dataStore.countUsers() > USER_LIMIT) {
log.warning("Failed registration attempt - user count exceeded.");
throw new CaprabankException("CapraBank is not accepting new customers at the moment.");
}
validateNotEmpty(firstName, "first name");
validateNotEmpty(lastName, "last name");
validateNotEmpty(email, "email");
validateNotEmpty(username, "username");
validateNotEmpty(password, "password");
if (dataStore.findUserByUsername(username) != null) {
log.warning("Failed registration attempt - username already exists: '" + username + ".");
throw new CaprabankException("The username is already in use.");
}
User newUser = new User();
newUser.accountNum = generateId();
newUser.firstName = firstName;
newUser.lastName = lastName;