I l @ ve RuBoard |
The Customer ClassYour first goal is to create a new customer registration page and customer login functionality. To do this, you're going to need some underlying beans to hold on to the user 's information. Looking back at your class diagram, you know that the Customer , AddressBook , and CreditCard objects will have to be implemented. Start with the simplest of the beans, the Customer bean. As with all beans, you should begin with the local storage and accessor methods for the properties of the class, as shown in Listing 8.1. Listing 8.1 Customer.javapackage com.bfg.customer; import java.util.Vector; public class Customer { private String last_name; private String first_name; private String email; private String password; private Vector addresses = new Vector();; private Vector wallet = new Vector(); static Category cat = Category.getInstance(Customer.class); private int customer_id; public int getCustomerId() { return customer_id; } public void setCustomerId(int id) { customer_id = id; } public String getLastName() { return last_name; } public void setLastName(String ln) { last_name = ln; } public String getFirstName() { return first_name; } public void setFirstName(String fn) { first_name = fn; } public String getEmail() { return email; } public void setEmail(String em) { email = em; } public String getPassword() { return password; } public void setPassword(String pw) { password = pw; } public Vector getWallet() { return wallet; } public Vector getAddressBook() { return addresses; } } No big surprises here ”it's the same boilerplate that anyone who has ever written a bean knows and loves. The only thing to notice is that, rather than implementing a separate class to hold the credit cards and addresses in aggregate, you merely use a vector to hold them. |
I l @ ve RuBoard |