Java万年历实验报告Word格式.docx

上传人:b****7 文档编号:22100912 上传时间:2023-02-02 格式:DOCX 页数:32 大小:310.48KB
下载 相关 举报
Java万年历实验报告Word格式.docx_第1页
第1页 / 共32页
Java万年历实验报告Word格式.docx_第2页
第2页 / 共32页
Java万年历实验报告Word格式.docx_第3页
第3页 / 共32页
Java万年历实验报告Word格式.docx_第4页
第4页 / 共32页
Java万年历实验报告Word格式.docx_第5页
第5页 / 共32页
点击查看更多>>
下载资源
资源描述

Java万年历实验报告Word格式.docx

《Java万年历实验报告Word格式.docx》由会员分享,可在线阅读,更多相关《Java万年历实验报告Word格式.docx(32页珍藏版)》请在冰豆网上搜索。

Java万年历实验报告Word格式.docx

{

newCalendarWindow().setVisible(true);

}

}

第一个包

packageaccount;

publicclassAccount{

privateStringname;

privateStringpassWord;

publicAccount(Stringname,StringpassWord)

=name;

=passWord;

publicStringgetName()

returnname;

publicvoidsetName(Stringname)

publicStringgetPassWord()

returnpassWord;

publicvoidsetPassWord(StringpassWord)

@Override

publicStringtoString(){

return"

账户"

+name+"

密码"

+passWord;

publicbooleanequals(Objectobj){

if(this==obj)

returntrue;

if(obj==null)

returnfalse;

if(getClass()!

=())

Accountother=(Account)obj;

if(name==null){

if!

=null)

returnfalse;

}elseif(!

if(passWord==null){

returntrue;

第二个包(含三个类)

packagecalendar;

publicclassCalendarWindowextendsimplementsObserver{

privateTimetime;

privateintyear;

privateintmonth;

privateintday;

privateWeekweek;

privateDatexcurrent;

privateILoginServiceloginService;

privatebooleanisLogin;

privateIEventServiceeventService;

/**CreatesnewformTimeWindow*/

publicCalendarWindow(){

initComponents();

setLocationRelativeTo(null);

loginService=newLoginService();

eventService=newEventService();

init();

privatevoidinit(){

;

()*2+9);

time=newTime();

week=newWeek();

current=();

year=();

month=();

day=();

TimeUnitunit=();

()+"

"

);

initTable(current);

initComboBox();

initInfoTextArea(current);

oString());

Datextemp=newDatex(year,month,1);

initTable(temp);

initInfoTextArea(temp);

privatevoidmonthComboBoxActionPerformedevt){

month=().toString());

privatevoidtodayActionPerformedevt){

initTable());

privatevoidloginButtonActionPerformedevt){

isLogin=();

if(isLogin){

(this,"

已登录,不能重复登录!

return;

}

newloginDialog(this,loginService).setVisible(true);

if(isLogin)

setTitle("

万年历(登录状态:

*已登录*)"

privatevoideventButtonActionPerformedevt){

newEventDialog(this,newDatex(year,month,day),eventService).setVisible(true);

else{

个人文档已加密,如需访问请先登录!

privatevoidtableMouseClickedevt){

introw=();

intcolumn=();

if(row<

0||column<

0)

try{

;

(1);

day=(row,column).toString());

initInfoTextArea(newDatex(year,month,day));

}catch(Exceptione){

publicclassCalendarx{

publicCalendarx(intyear,intmonth,intday)

if(year<

=0)

thrownewIllegalArgumentException("

输入的年份有误!

if(month<

=0||month>

12)

输入的月份有误!

if(day<

=0||day>

(year,month))

输入的日期有误!

current=newDatex(year,month,day);

publicDatexgetcurrent(){

returncurrent;

publicDatexgetPreviousDate(){

intyear=();

intmonth=();

intday=();

if()!

=1)

returnnewDatex(year,month,day-1);

if()==1)

returnnewDatex(year-1,12,(year-1,12));

returnnewDatex(year,month-1,(year,month-1));

publicDatexgetNextDate(){

if(year,month)!

=day)

returnnewDatex(year,month,day+1);

if(month==12){

returnnewDatex(year+1,1,1);

returnnewDatex(year,month+1,1);

oString();

Stringinfos=();

try{

if(current).equals(state)

&

&

(current).equals(infos)){

(false);

return;

}

}catch(Exceptione){

}

intresult=(this,"

今日日程已经改变,是否保存"

"

关闭信息框"

;

if(result=={

(current,state,infos);

(false);

return;

}catch(RuntimeExceptione){

setVisible(false);

(parent,"

建立"

+()

+"

日程时出错,请重新建立!

privatevoidstateComboBoxActionPerformedevt){

Stringstate;

state=().toString();

(state);

if(!

().equals("

(无)"

))

(true);

设置日程状态出错!

privatevoidstateItemActionPerformedevt){

if().equals("

state=(current);

privatevoidexitItemActionPerformedevt){

setVisible(false);

privatevoidsaveItemActionPerformedevt){

(current,state,infos);

packageevent;

publicclassEventServiceimplementsIEventService{

publicStringreadAll(Datexdate)throwsRuntimeException{

if(date==null)

thrownewRuntimeException("

日期不能为null!

Stringresult="

;

FileInputStreamin=newFileInputStream("

schedules/"

+());

Scannerscanner=newScanner(in);

if())

();

while())

result+=();

();

}catch(IOExceptione){

从"

+()+"

磁盘读信息时出错!

returnresult;

publicvoidsaveAll(Datexdate,Stringstate,Stringinfo)

throwsRuntimeException{

if(date==null||state==null)

日期和日程状态都不能为null!

FileWriterout=newFileWriter("

+());

(state+"

\n"

+info);

}catch(IOExceptione1){

信息写入"

磁盘时出错!

publicStringgetState(Datexdate)throwsRuntimeException{

result=();

publicinterfaceIEventService{

rim();

if()<

3||()>

15){

("

×

errorNumber1++;

}else{

√"

errorNumber1--;

账户名不合法,此功能无法运行!

privatevoidanswerTextFocusLostevt){

errorNumber2=0;

problem=().toString();

answer=().trim();

=0){

errorNumber2++;

errorNumber2--;

问题选择有误,此功能无法运行!

packagelogin;

publicinterfaceILoginService{

etVisible(true);

privatevoidgainAccountMouseClickedevt){

newRegisterAccountDialog(this,loginService).setVisible(true);

Stringname=();

if("

)){

(this,"

账户不能空!

StringpassWord=());

密码不能空!

(name,passWord);

(false);

(this,());

import.*;

publicclassLoginServiceimplementsILoginService{

privateStringnewName;

privateStringnewPassWord;

publicAccountloginAccount(StringnewName,StringnewPassWord)

=newName;

=newPassWord;

returnjudgeAccount(newName,newPassWord);

privateString[]readInfo(StringfileName,intnum){

String[]result=newString[num];

FileInputStreamin=newFileInputStream(fileName);

for(inti=0;

i<

num;

i++)

if())

result[i]=();

+fileName+"

privatevoidwriteInfo(StringfileName,Stringinfo)

FileWriterout=newFileWriter(fileName);

(info);

privateAccountjudgeAccount(StringnewName,StringnewPassWord){

String[]info;

if(newName==null||newPassWord==null)

输入的账户和密码都不能为null"

info=readInfo("

account"

2);

thrownewRuntimeException());

}

if(!

info[0].equals(newName))

输入的账户名有误!

info[1].equals(newPassWord))

输入的密码有误!

returnnewAccount(info[0],info[1]);

publicvoidregisterAccount(StringnewName,StringnewPassWord,

Stringproblem,Stringanswer)throwsRuntimeException{

if(newName==null||problem==null||answer==null

||newPassWord==null)

输入的账户,密码,问题和答案都不能为null"

writeInfo("

newName+"

+newPassWord+"

+problem+"

+answer);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 院校资料

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1