java课设报告.docx
《java课设报告.docx》由会员分享,可在线阅读,更多相关《java课设报告.docx(47页珍藏版)》请在冰豆网上搜索。
java课设报告
SoftwareRequirementsSpecification
Version
<2014/01/13>
<>
Contents
1.
1.0.Introduction-----------------------------------------------------------1
1.1.Purpose-----------------------------------------------------------------1
1.2.ScopeofProject-------------------------------------------------------1
2.
2.0.OverallDescription-------------------------------------------------2
2.1.SystemEnvironment------------------------------------------------3
2.2.FunctionalRequirementsSpecification-------------------------3
2.3.UserInterfaceSpecification---------------------------------------4
2.4.Non-FunctionalRequirements------------------------------------7
Index----------------------------------------------------------------------------8
ListofFigures
1.PictureofTheintroductionoftheintegralproject……………..….2
2.PictureofHowtousetheproject………………………………….…3
3.PictureofSortMenu……………………………………………..……..4
4.Pictureofshow……………………………………….…………….…..4
5.Pictureofaddinterface………………………………………………5
6.PictureThemaininterfaceafteradd…………………………………5
7.Pictureofeditinterface………………………………………………6
8.Pictureofsaveinterface………………………………………………6
9.Pictureofrelationship…………………………………………………7
1.0.Introduction
Thispageisthestartingpointintoaseriesofpagesthatattempttogiveacompleteexampleofobject-orientedanalysis,design,andprogrammingappliedtoasmallsizeproblem:
asimpleaddressbook.Thesepagesaresimilarinstyletoanother,morecomplicatedsetofpagesIdevelopedearlier:
ASimulationofanAutomatedTellerMachine(ATM).IdevelopedboththatsetofpagesandthisinthebeliefthatstudentswouldbenefitfromseeingacompleteexampleofOOmethodologyappliedtoasingleproblem.TheproblemdocumentedbythissetofpagesismuchsimplerthantheATMExample,andsoismoreaccessibletoundergraduatestudentsseeingOOmethodologyandUMLforthefirsttime.
1.1.Purpose
Thesoftwaretobedesignedisaprogramthatcanbeusedtomaintainanaddressbook.Anaddressbookholdsacollectionofentries,eachrecordingaperson'sfirstandlastnames,address,city,state,zip,andphonenumber.
1.2.ScopeofProject
1、Asingleentityobjectrepresentingthecurrentaddressbookthattheprogramisworkingwith(AddressBook).
2、Anarbitrarynumberofentityobjects,eachrepresentingoneofthepeoplethatisinthecurrentaddressbook(Person).
3、Aboundaryobjectrepresentingtheinterfacebetweentheaddressbooksystemandthehumanuser(AddressBookGUI).
4、Aboundaryobjectrepresentingtheinterfacebetweentheaddressbooksystemandthefilesystemondisk(FileSystem).
5、AcontrollerobjectthatcarriesouttheusecasesinresponsetousergesturesontheGUI(AddressBookController).
TheOpenExistingAddressBookusecaseisinitiatedwhentheuserchooses"Open"fromtheFilemenu.
IfthecurrentaddressbookcontentshavebeenchangedsincethelastsuccessfulNew,Open,Save,orSaveAs...operationwasdone,theOffertoSaveChangesextensionisexecuted.
Unlesstheusercancelstheoperation,aloadfiledialogisdisplayedandtheuserisallowedtochooseafiletoopen.
Oncetheuserchoosesafile,thecurrentaddressbookisreplacedbytheresultofreadinginthespecifiedaddressbook.Thisresultsinthelistofnamesinthemainwindowbeingreplacedbythenamesintheaddressbookthatwasread,thefilethatwasopenedbecomingthecurrentfile,anditsnamebeingdisplayedasthetitleofthemainwindow.
2.0.OverallDescription
PictureofTheintroductionoftheintegralproject
PictureofHowtousetheproject
2.1SystemEnvironment
Java:
-JRE 1.6, JDK 1.6,JVM 1.6
2.2FuntionalRequirementsSpecification
Itmustbepossibletoaddanewpersontoanaddressbook,toeditexistinginformationaboutaperson(excepttheperson'sname),andtodeleteaperson.Itmustbepossibletosorttheentriesintheaddressbookalphabeticallybylastname(withtiesbrokenbyfirstnameifnecessary),orbyZIPcode(withtiesbrokenbynameifnecessary).Itmustbepossibletoprintoutalltheentriesintheaddressbookin"mailinglabel"format.
Itmustbepossibletocreateanewaddressbook,toopenadiskfilecontaininganexistingaddressbooktocloseanaddressbook,andtosaveanaddressbooktoadiskfile,usingstandardNew,Open,Close,SaveandSaveAs...Filemenuoptions.Theprogram'sFilemenuwillalsohaveaQuitoptiontoallowclosingallopenaddressbooksandterminatingtheprogram.
2.3UserInterfaceSpecification
(PictureofSortMenu)
(Pictureofshow)
(Pictureofaddinterface)
(PictureThemaininterfaceafteradd)
(Pictureofeditinterface)
(Pictureofsaveinterface)
2.4Non-FunctionalRequirements
(Pictureofrelationship)
Index
ClassofAddressBook:
packageaddressbook;
importjava.io.File;
importjava.io.Serializable;
importjava.util.Collections;
importjava.util.Observable;
importjava.util.Vector;
publicclassAddressBookextendsObservableimplementsSerializable{
privateVectorcollection;
privatebooleanchangedSinceLastSave;
publicvoidsetChangedSinceLastSave(booleanchangedSinceLastSave){
this.changedSinceLastSave=changedSinceLastSave;
}
publicbooleangetChangedSinceLastSave(){
//TODOAuto-generatedmethodstub
returnthis.changedSinceLastSave;
}
Filefile;
publicFilegetFile(){
returnfile;
}
publicvoidsetFile(Filefile){
this.file=file;
}
publicvoidsetUnchangedSinceLastSave()
{
this.changedSinceLastSave=false;
}
publicAddressBook(){
super();
this.collection=newVector();
this.file=null;
this.changedSinceLastSave=false;
}
publicvoidaddPerson(StringfirstName,StringlastName,Stringaddress,
Stringcity,Stringstate,Stringzip,Stringphone)
{
//addthispersoninvector
Personp=newPerson(firstName,lastName,address,city,state,zip,phone);
collection.addElement(p);
changedSinceLastSave=true;
setChanged();//wewillmadechanges
notifyObservers();//sotelltoobservertoupdate()
}
publicString[]getNames()
{
String[]names=newString[collection.size()];
for(inti=0;i{
Personp=(Person)collection.get(i);
names[i]=p.getFullName();
}
returnnames;
}
publicString[]getPersonalInformation(Stringname){
//TODOAuto-generatedmethodstub
//findoutindexofapersonwhosenameisname
for(inti=0;i{
Personp=(Person)collection.elementAt(i);
StringpersonName=p.getFullName();
if(personName.equals(name))
{
String[]information={p.getAddress(),p.getCity(),p.getState(),
p.getZip(),p.getPhone()};
returninformation;
}
}
returnnull;
}
privateintfindIndex(Stringname)
{
for(inti=0;i<=collection.size();i++)
{
Personp=(Person)collection.elementAt(i);
StringpersonName=p.getFullName();
if(personName.equals(name))
{
returni;
}
}
return-1;
}
publicvoidupdatePerson(Stringname,Stringaddress,Stringcity,
Stringstate,Stringzip,Stringphone){
//TODOAuto-generatedmethodstub
//firstweneedtofindaperson
intindex=findIndex(name);
if(index>=0)
{
//getapersonfromlist
Personp=(Person)collection.elementAt(index);
//updateperson
p.update(address,city,state,zip,phone);
changedSinceLastSave=true;
setChanged();//wewillmadechanges
notifyObservers();//sotelltoobservertoupdate()
}
}
publicvoidremovePerson(Stringname)
{
intindex=findIndex(name);
if(index>=0)
{
//getapersonfromlist
Personp=(Person)collection.elementAt(index);
//updateperson
collection.removeElementAt(index);
changedSinceLastSave=true;
setChanged();//wewillmadechanges
notifyObservers();//sotelltoobservertoupdate()
}
}
publicvoidsortByName(){
//TODOAuto-generatedmethodstub
Collections.sort(collection,newPerson.CompareByName());
//checklastname,thenfirstname
//updateGUI
changedSinceLastSave=true;
setChanged();
notifyObservers();
}
publicvoidsortByZip(){
//TODOAuto-generatedmethodstub
Collections.sort(collection,newPerson.CompareByZip());
//checklastname,thenfirstname
//updateGUI
changedSinceLastSave=true;
setChanged();
notifyObservers();
}
publicintsearch(StringlastSearchCriterion,intstartingIndex){
//TODOAuto-generatedmethodstub
for(inti=0;i{
Personp=collection.elementAt(i);
if(p.contains(lastSearchCriterion))
{
returni;
}
}
return-1;
}
}
ClassofAddressBookApplication:
packageaddressbook;
publicclassAddressBookApplication{
privateFileSystemfileSystem;
privateAddressBookControllercontroller;
//staticAddressBookControllercontroller;
privateAddressBookApplication()
{
fileSystem=newFileSystem();
controller=newAddressBookController(fileSystem);
}
/**
*@paramargs
*/
publicstaticvoidmain(String[]args){
//TODOAuto-generatedmethodstub
//AddressBookGUIframe=newAddressBookGUI(controller);
//frame.setLocation(900,150);
//frame.setSize(400,320);
//frame.setVisible(true);
newAddressBookApplication();
}
}
ClassofAddressBookController:
packageaddressbook;
importjava.io.File;
importjava.io.IOException;
importjavax.swing.JFileChooser;
importjavax.swing.JOptionPane;
publicclassAddressBookController{
publicbooleanPROCEED=true;
publicbooleanDONOT_PROCEED=false;
privateStringlastSearchCriterion;
priv