Review this generated member-account class against the stated task.
Represent a member with a nonblank stable ID, nonnegative credits, privately owned roles, safe debit behavior, and ID-based equality that works in hash collections.
Java
import java.util.List;
public class MemberAccount {
public String id;
public int credits;
private final List<String> roles;
public MemberAccount(String id, int credits, List<String> roles) {
this.id = id;
this.credits = credits;
this.roles = roles;
}
public void debit(int amount) {
credits -= amount;
}
public List<String> roles() {
return roles;
}
@Override
public boolean equals(Object value) { return value instanceof MemberAccount account && id.equals(account.id); }
}
generated code is illustrative, not from any one model