📄 add.java
字号:
package agenda;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.Hashtable;
/**
* 类名:Add
* 功能:用于加入一项会议内容到会议存储表中
* 作者:孟欣(05376053)
* 开发环境:Eclipse 3.2、JDK 1.5.0
* 版本号:3.0
* 日期: 2008/4/9
*
*/
public class Add {
DataBase meetingDB = null;
static Hashtable<String, DataBase> hashMeeting = new Hashtable<String, DataBase>();
private Users tpUsers = null;
public Add(String Rname,String Rpassword,String other, String startTime, String endTime, String table) throws ParseException {
/* SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH:mm");
Date starDate = DisposeDate.StoD(startTime);
Date endDate = DisposeDate.StoD(endTime);
System.out.println(sdf.format(starDate));
System.out.println(sdf.format(endDate));
*/
// tpUsers = new Users(Rname, Rpassword);
if(Register.hashUser.containsKey(Rname)){
tpUsers = Register.hashUser.get(Rname);
if(tpUsers.userName.equals(Rname)&&tpUsers.password.equals(Rpassword)){
if(hashMeeting.isEmpty()|| !(hashMeeting.containsKey(table))){ //如果表是空或者是没有"table"键时,则成功插入
if(Register.hashUser.containsKey(other))
{
if(DisposeDate.checkSeq(startTime, endTime))
{
if(checkMTime(Rname, other, startTime, endTime)){
meetingDB = new DataBase(Rname,other, startTime, endTime, table);
hashMeeting.put(table, meetingDB); //以table作为 hashMeeting的主键
System.out.println("Congratulatinos! Add meeting is ok!\n");
}
else System.out.println("Error! The time of the meeting clishs with the old one...\n");
}
else System.out.println("Error!The start time can't be earler than the end time...\n");
}
else System.out.print("Error! Your meeting collaborator doesn't exits...\n");
}
else System.out.println("Meeting with the name \""+table+" \"has exist!\n");
}
else{
System.out.println("Sorry, your password isn't right!");
System.out.println("Please correct it or Regist a new accounts...\n");
}
}
else{
System.out.println("Sorry,the name \""+Rname+"\" isn't exist!");
System.out.println("Please regist a new accounts first...\n");
}
} //end Add();
/**
* 用于判断用户输入的会议时间是否与自己或是另一与会者已有会议时间冲突
* @param Rname
* @param other
* @param startTime
* @param endTime
* @return
*/
static boolean checkMTime(String Rname, String other, String startTime, String endTime)
{
DataBase tpDB = new DataBase();
Enumeration en = hashMeeting.keys();
String strTable = null;
while(en.hasMoreElements()){
strTable = en.nextElement().toString();
tpDB = hashMeeting.get(strTable);
if(Rname.equals(tpDB.userName)||other.equals(tpDB.userName)){
if( !DisposeDate.checkClash(tpDB.startTime, tpDB.endTime, startTime, endTime))
{
return false;
}
}
}
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -