📄 meeting.java
字号:
/**
*
*/
package sysu.agenda.model;
import java.text.ParseException;
import java.util.Date;
import sysu.agenda.ctrl.InputHelper;
import sysu.agenda.exception.ParameterException;
/**
* @author Administrator
*
*/
public class Meeting {
private String user = new String();
private String other = new String();
private String title = new String("no title");
private Date start = new Date();
private Date end = new Date();
/*
* default constructor
*/
public Meeting() {
}
/*
* constructor with parameters
*/
public Meeting(String user, String other, String title, Date start, Date end)
throws ParameterException {
this.setUser(user, other);
this.setOther(other, user);
this.setTitle(title);
this.setStart(start, end);
this.setEnd(end, start);
}
/**
* @param args
* @return void
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Meeting m1 = new Meeting("a", "b", "t", InputHelper.getInstance()
.StingToDate("4-5-2009"), InputHelper.getInstance()
.StingToDate("4-6-2009"));
System.out.println(m1.toString());
} catch (ParameterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/*
* setter for start time
*/
public void setStart(Date start, Date end) throws ParameterException {
if (start != null && !start.after(end))
this.start = start;
else
throw new ParameterException("Meeting date overlapped");
}
/*
* getter for start time
*/
public Date getStart() {
return start;
}
/*
* setter for end of time
*/
public void setEnd(Date end, Date start) throws ParameterException {
if (end != null && !end.before(start))
this.end = end;
else
throw new ParameterException("Meeting date overlapped");
}
/*
* getter for the end of time of meeting
*/
public Date getEnd() {
return end;
}
/*
* setter for user
*/
public void setUser(String user, String other) throws ParameterException {
if (user != null && user.compareTo(other) != 0)
this.user = user;
else
throw new ParameterException("Username cannot be the same.");
}
/*
* getter for user
*/
public String getUser() {
return user;
}
public void setOther(String other, String user) throws ParameterException {
if (other != null && other.compareTo(user) != 0)
this.other = other;
else
throw new ParameterException("Username cannot be the same.");
}
public String getOther() {
return other;
}
public void setTitle(String title) throws ParameterException {
if (!title.isEmpty())
this.title = title;
else
throw new ParameterException("Title cannot be empty.");
}
public String getTitle() {
return title;
}
public String toString() {
return String
.format(
"Title: %1$s\nHost: %2$s; Guest: %3$s\nStart Time: %4$s\nEnd Time: %5$s\n",
this.title, this.user.toString(),
this.other.toString(), this.start, this.end);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -