Java Cart .

Java Cart AccountHolder java

package cart;

import cart.utils.ValidationUtils;

//AccountHolder
//author - Lawrence Truett - FluffyCat.com
//date - August 12, 2003 - San Diego, CA
public class AccountHolder {
    private String firstName;
    private String lastName;
    private Address address;
    private Phone phone;
    private EMail eMail;
    private Password password;
    
    public AccountHolder() {
        this.setFirstName("");
        this.setLastName("");
        this.setAddress(new Address());
        this.setPhone(new Phone());
        this.setEMail(new EMail());
        this.setPassword(new Password());
    }
    
    public AccountHolder(String firstNameIn, 
                         String lastNameIn, 
                         Address addressIn, 
                         Phone phoneIn, 
                         EMail eMailIn, 
                         Password passwordIn) {
        this.setFirstName(firstNameIn);
        this.setLastName(lastNameIn);
        this.setAddress(addressIn);
        this.setPhone(phoneIn);
        this.setEMail(eMailIn);
        this.setPassword(passwordIn);
    }
    
    public String getFirstName() {return firstName;}
    public void setFirstName(String firstNameIn) {
        this.firstName = firstNameIn;
    }
    public boolean isFirstNameValid() {
        if (ValidationUtils.isStringBlank(this.getFirstName())) {
            return false;
        } else {
            return true;
        }
    }
    public String firstNameErrorString() {
        if (this.isFirstNameValid()) {
            return " ";
        } else {
            if (ValidationUtils.isStringBlank(this.getFirstName())) {
                return "First Name Is Blank";
            } else {
                return this.getFirstName() + " has an error ";
            }
        }
    }
    
    
    public String getLastName() {return lastName;}
    public void setLastName(String lastNameIn) {
        this.lastName = lastNameIn;
    }
    public boolean isLastNameValid() {
        if (ValidationUtils.isStringBlank(this.getLastName())) {
            return false;
        } else {
            return true;
        }
    }
    public String lastNameErrorString() {
        if (this.isLastNameValid()) {
            return " ";
        } else {
            if (ValidationUtils.isStringBlank(this.getLastName())) {
                return "Last Name Is Blank";
            } else {
                return this.getLastName() + " has an error ";
            }
        }
    }    
    
    public Address getAddress() {return address;}
    public void setAddress(Address addressIn) {
        this.address = addressIn;
    }
    
    public Phone getPhone() {return phone;}
    public void setPhone(Phone phoneIn) {
        this.phone = phoneIn;
    }
    
    public EMail getEMail() {return eMail;}
    public void setEMail(EMail eMailIn) {
        this.eMail = eMailIn;
    }
    
    public Password getPassword() {return password;}
    public void setPassword(Password passwordIn) {
        this.password = passwordIn;
    }
    
    public boolean isValid() {
        if (
        (isFirstNameValid()) &&
        (isLastNameValid()) &&
        (getPhone().isValid())
        ) {
            return true;
        } else {
            return false;
        }
    }
    
    //method used for data input
    public boolean isValidOrNull() {
        if (
        (getPhone().isValidOrNull())
        ) {
            return true;
        } else {
            return false;
        }
    }
    
    public String toString() {
        return ("Account Holder " + 
            getFirstName().toString() + " " + 
            getLastName().toString());
    }
}
To download source right-click here and "Save As...".
Comments
Sign in to be the first to comment on Java Cart AccountHolder java.