?? 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 + -