package login;
import java.util.*;
public class LogBean
{
	private String username;
	private String password;
	private String email;
	private Hashtable errors;
	public LogBean()
	{
		username=" ";
		password=" ";
		email=" ";
		errors=new Hashtable();
	}
	public String getUsername()
	{
		return username;
	}
	public String getPassword()
	{
		return password;
	}
	public String getEmail()
	{
		return email;
	}
	public void setUsername(String name)
	{
		username=name;
	}
	public void setPassword(String pass)
	{
		password=pass;
	}
	public void setEmail(String mail)
	{
		email=mail;
	}
	public void setErrors(String key, String msg)
	{
		errors.put(key,msg);
	}
	public boolean validate()
	{
		boolean ok=true;
		if(username.equals(" "))
		{
			errors.put("username","Please input your name");
			username=" ";
			ok=false;
		}
		if(password.equals(" ")||(password.length()>10||password.length()<6))
		{
			errors.put("password","Please input a password with length of 6-10 						characters");
			password=" ";
			ok=false;
		}
		if(email.equals(" ")||(email.indexOf('@')==-1)||(email.indexOf('.')==-1))
		{
			errors.put("email","the email is invalid");
			email=" ";
			ok=false;
		}
			return ok;
	}
	public String getErrorMsg(String message)
	{
		String errorMsg=(String)errors.get(message.trim());
		return((errorMsg==null) ? " ":errorMsg);
	}
}
