class UserRegistration {

    public void registerNewUser(String emailAddress) throws UserAlreadyRegisteredException, EmailFailedException {
        if (database.hasUser(emailAddress)) {
            throw new UserAlreadyRegisteredException();
        }

        if(!emailSender.sendRegistrationEmail(new RegistrationEmail(emailAddress))) {
            throw new EmailFailedException();
        }
        database.addUser(emailAddress);
    }

    public  UserRegistration(Database database, EmailSender emailSender);

}