📄 registermodel.java
字号:
/*
* 创建日期 2005-9-6
*
* TODO 要更改此生成的文件的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
package fsc.models;
/**
* @author chenhao
*
* TODO 要更改此生成的类型注释的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
import fsc.models.exceptions.*;
import fsc.util.*;
public class RegisterModel {
public static final int ROWS=6;
public static final String TAG="REGISTER_MODEL";
private String userName;
private String password;
private char sex;
private String question;
private String answer;
private String email;
/**
* @param content
* @throws InvalidEmailException
* @throws InvalidAnswerException
* @throws InvalidQuestionException
* @throws InvalidSexException
* @throws InvalidPassswordException
* @throws InvalidUserNameException
*/
public RegisterModel(String content) throws InvalidUserNameException, InvalidPassswordException, InvalidSexException, InvalidQuestionException, InvalidAnswerException, InvalidEmailException {
fromString(content);
// TODO Auto-generated constructor stub
}
/**
*
*/
public RegisterModel() {
// TODO Auto-generated constructor stub
}
public String getUserName()
{
return userName;
}
public String getPassword()
{
return password;
}
public char getSex()
{
return sex;
}
public String getQuestion()
{
return question;
}
public String getAnswer()
{
return answer;
}
public String getEmail()
{
return email;
}
public void setUserName(String u) throws InvalidUserNameException
{
if(u.equals(""))
{
throw new InvalidUserNameException("Empty user name");
}
userName=u;
}
public void setPassword(String p) throws InvalidPassswordException
{
if(p.equals(""))
{
throw new InvalidPassswordException("Empty password");
}
password=p;
}
public void setSex(char s) throws InvalidSexException
{
if(s=='M'||s=='F')
{
sex=s;
}
else
{
throw new InvalidSexException("No such sex");
}
}
public void setQuestion(String q) throws InvalidQuestionException
{
if(q.equals(""))
{
throw new InvalidQuestionException("Empty Question");
}
question=q;
}
public void setAnswer(String a) throws InvalidAnswerException
{
if(a.equals(""))
{
throw new InvalidAnswerException("Empty Answer");
}
answer=a;
}
public void setEmail(String e) throws InvalidEmailException
{
if(e.equals(""))
{
throw new InvalidEmailException("Empty user name");
}
email=e;
}
public String toString()
{
return TAG+"\n"+userName+'\n'+password+'\n'+sex+'\n'+question+'\n'+answer+'\n'+email+'\n';
}
public void fromString(String content)
throws InvalidUserNameException, InvalidPassswordException, InvalidSexException, InvalidQuestionException, InvalidAnswerException, InvalidEmailException
{
StringProcessor sp= new StringProcessor(content);
setUserName(sp.getLine());
setPassword(sp.getLine());
setSex(sp.getLine().charAt(0));
setQuestion(sp.getLine());
setAnswer(sp.getLine());
setEmail(sp.getLine());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -