Array list

I am creating a registration system where you add in members details and it saves them in an array list.

I need it to produce an error message if you try and add an exisiting member but cant seem to crack it. Does any one have any ideas?

Cheers

Comments

  • : I am creating a registration system where you add in members details and it saves them in an array list.
    :
    : I need it to produce an error message if you try and add an exisiting member but cant seem to crack it. Does any one have any ideas?
    :
    : Cheers
    :
    The way to solve this is to assume that the member doesn't exist, and search for him in the list. If you find him, then he already exists and some error should be shown. In code:
    [code]
    boolean newMember = true;
    for (MemberObject o : memberArrayList) {
    if (o.matches(SearchCriteria)
    b = false;
    if (b) {
    addNewMember();
    } else {
    error("Member already exists");
    }
    [/code]
    You need to change the names to suit your code.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion