Member data can be a class type:
public class User {
private Account primary;
private Account secret;
public User(String username, pin) {
primary = new Account(username, pin);
secret = new Account("xxx" + username, pin);
}
public Account getPrimary() {
return primary;
}
public Account getSecret() {
return secret;
}
public void clearAllFailures() {
primary.resetFailures();
secret.resetFailures();
}
public boolean isAuthenticated(String possible_user, int possible_pin) {
if ( possible_user.subString(0, 3).equals("xxx") ) {
return secret.isAuthenticated(possible_user, possible_pin);
} else {
return primary.isAuthenticated(possible_user, possible_pin);
}
}
public boolean isAcceptableNewPin(int candidate) {
return primary.isAcceptableNewPin(candidate);
}
public boolean isMyAccount(Account other)
{
return primary.getUser().equals()(other.getUser())
|| secret.getUser().equals()(other.getUser());
}
}