C++通訊錄管理系統(tǒng)課程設計_第1頁
C++通訊錄管理系統(tǒng)課程設計_第2頁
C++通訊錄管理系統(tǒng)課程設計_第3頁
C++通訊錄管理系統(tǒng)課程設計_第4頁
C++通訊錄管理系統(tǒng)課程設計_第5頁
已閱讀5頁,還剩10頁未讀 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

通訊錄管理問題描述編寫一個簡單的通訊錄管理程序。通訊錄記錄有姓名,地址(省、市(縣)、街道),電話號碼,郵政編碼等四項?;疽蟪绦驊峁┑幕竟芾砉δ苡校禾砑樱杭丛黾右粋€人的記錄到通信錄中顯示:即在屏幕上顯示所有通信錄中的人員信息,應能分屏顯示。存儲:即將通訊錄信息保存在一個文件中。裝入:即將文件中的信息讀入程序。查詢:可根據(jù)姓名查找某人的相關信息,若找到顯示其姓名、地址、電話號碼和郵政編碼。修改:可修改一個人的除姓名外其它信息。測試數(shù)據(jù)程序應輸入不少于10個人員的通訊錄信息,應考慮到人員可以同名的情況。實現(xiàn)提示程序可用一個動態(tài)數(shù)組來管理人員信息,每個人員的姓名,地址,電話號碼和郵政編碼用一個類Cperson來實現(xiàn),作為動態(tài)數(shù)組的值指針指向這些Cperson類對象,通過動態(tài)數(shù)組的遍歷可以操作這些數(shù)據(jù)。目錄【摘要】 第1章概述1.1系統(tǒng)實現(xiàn)的目標1.2系統(tǒng)實現(xiàn)方案 1.3系統(tǒng)實現(xiàn)環(huán)境 1.4具體的開發(fā)方法第2章系統(tǒng)設計 2.1總體設計 2.2類設計 2.3數(shù)據(jù)結構 2.4界面設計 第3章系統(tǒng)實現(xiàn) 【摘要】日益繁多的人際交往使得我們很難記住與每個人之間的聯(lián)系方式,通訊錄能夠便捷的給我們帶來所需要的相關信息。而隨著計算機的普及,人們的生活擺脫了傳統(tǒng)式的記事本、電話簿,越來越多的靠計算機或者手機中的電話簿程序來幫助人們記住這些事情,極其簡便。這就需要有一個使用的通訊錄管理系統(tǒng),用戶可以方便的通過自己電腦的通訊錄管理系統(tǒng),來隨時查閱自己所需要的信息,而不必再大費周折去翻開那繁瑣的記事本。通訊錄管理系統(tǒng)是一個專門針對儲存用戶聯(lián)系方式以及一些簡單個人信息的實用管理系統(tǒng),它方便了用戶對眾多客戶、朋友、同事等個人信息的儲存和快速查閱的功能,大大減少了查找過程的時間。1.1系統(tǒng)實現(xiàn)的目標(1)錄入:通訊錄信息包括:姓名,電話,地址,E-mail,郵編等信息。(2)更新:能插入、刪除通訊錄信息。.(3)瀏覽:能夠查看所有的通訊錄信息。(4)查詢:能實現(xiàn)指定姓名信息查詢或指定編號查詢功能。(5)系統(tǒng)以菜單方式工作,界面友好,易于操作。1.2系統(tǒng)實現(xiàn)方案為實現(xiàn)系統(tǒng)功能,本程序主要分為五個模塊。它們分別為:輸入一個信息、刪除一個信息、查詢一個信息、插入一個信息、列出所有的信息、退出該程序。這五個函數(shù)再通過主函數(shù)調用分別得以實現(xiàn)。主函數(shù),首先提供了程序運行時的友好界面,列出了清單,提供用戶做出選擇,以便決定使用通訊錄的哪種功能。然后,通過執(zhí)行多分支選擇語句——switch語句,分別實現(xiàn)其它各個函數(shù)的調用功能。1.3系統(tǒng)實現(xiàn)環(huán)境通過VC++6.0用C++語言對程序進行編寫設計在windows界面下用DOS訪問1.4具體的開發(fā)方法用面向對象的程序設計方法,運用C++語言編寫程序進行該學生考勤管理系統(tǒng)的詳細設計,使之能提供錄入、顯示、查找、刪除、修改的功能。最后在VC++6.0環(huán)境下編寫和調試程序,進而完成系統(tǒng)的實現(xiàn)。第2章系統(tǒng)設計2.1總體設計功能:1.輸入聯(lián)系人的信息2.顯示聯(lián)系人的信息3.查找聯(lián)系人的信息4.刪除聯(lián)系人的信息5.編輯人的信息一程序分析階段該程序有六項功能,即添加、顯示、存儲、裝入、查詢、修改,要完成此六項功能必須有六項實現(xiàn)該功能的函數(shù),和類的構造相聯(lián)系知此六項功能即為類的行為,此為行為抽象。該程序又有四項屬性,即姓名、地址、電話號碼、郵政編碼,又因為地址有三項成員,即省、市、街道,由此可知可將數(shù)據(jù)成員分為兩個類,即Cperson類和Address類,此為類的數(shù)據(jù)成員。此為數(shù)據(jù)抽象。至此類的數(shù)據(jù)成員和行為成員形成。二程序設計階段由于人員信息較多,可考慮使用對象數(shù)組來管理人員信息,作為動態(tài)數(shù)組的值指針指向這些Cperson類對象,通過動態(tài)數(shù)組的遍歷可以操作這些數(shù)據(jù)。程序應輸入不少于10個人員的通訊錄信息,應考慮到人員可以同名的情況。當人員同名是應該考慮其他的屬性。三程序編程階段1:編程之前應該先畫出該類的UML圖。Cperson—phonenumber:int—Cperson—phonenumber:int—lastdate:int—name:string—address:Address—postnumber:string—balance:double—time:double—<<const>>price:double—<<static>>n:int+Cperson():void+getbalance():void+gettime():void+record(date:int,account:double):double+show():void+select(name:string):void+alter(phonenumber:int):void+insert(phonenumber:int):voidAddress—province:string—city:string—street:string+Address()+getAddress()+Address(Address&add)第三章系統(tǒng)實現(xiàn)//Address類的設計#ifndefAddress_h#defineAddress_h#include<string>classAddress{private: std::stringprovince; std::stringcity; std::stringstreet;public: Address(){} Address(std::stringprovince,std::stringcity,std::stringstreet); voidgetaddress(std::stringprovince,std::stringcity,std::stringstreet); Address(Address&address1); ~Address();};#endif//Cperson類的設計#ifndefCperson_h#defineCperson_h#include<string>classCperson//通信用戶類{public:Cperson(); Cperson(intphonenumber,intdate,char*name1,Address&address,std::stringpostnumber); doublegetbalance()const{returnbalance;} doublegettime()const{returntime;} voidinputmoney(intdate,doubleaccount); voidrecord(intdate,doubleaccount); voidsettle(intdate,doubletime); staticunsignedintgettotal(){returnn;} voidinput(intphonenumber,char*name1,Address&address,std::stringpostnumber,doublebalance,doubletime); voidshow()const;voidselect(char*name); voidalter(intphonenumber1,char*name1); voidinsert(intphonenumber); ~Cperson();private: intphonenumber;//電話號碼 intlastdate;//充值日期 char*name;//用戶姓名 Addressaddress;//用戶地址 std::stringpostnumber;//用戶所在地的郵政編碼 doublebalance;//余額 doubletime;//通話時間 staticdoubleprice;//話費單價 staticunsignedintn;//用戶總人數(shù)};#endif//Address類的實現(xiàn)#include"Address.h"#include<string>usingnamespacestd;Address::Address(stringprovince,stringcity,stringstreet){province=province; city=city; street=street;}Address::getaddress(stringprovince,stringcity,stringstreet){address=province+city+street;}Address::~Address(){}Address::Address(Address&address1){province=vince; city=address1.city; street=address1.street;}//Cperson類的實現(xiàn)#include"Address.h"#include"Cperson.h"#include<iostream>#include<string>#include<cmath>usingnamespacestd;Cperson::Cperson(){}Cperson::Cperson(intdate,intphonenumber,char*name1,Address&address1,stringpostnumber){ lastdate=date; phonenumber=phonenumber;name=newchar[strlen(name1)+1]; //申請動態(tài)內存空間 strcpy(name,name1); //字符串的賦值 Address=address1; postnumber=postnumber; balance=0; time=0; price=price;cout<<"\t#"<<name<<"iscreated"<<endl; n++;}voidCperson::record(intdate,doubleaccount){ lastdate=date;balance=balance+account; cout<<date<<"\t#"<<name<<"\t"<<account<<"\t"<<balance<<endl;}voidCperson::inputmoney(intdate,doubleaccount){ cout<<"你已經成功充值"<<account<<endl; record(date,account);}voidCperson::settle(intdate,doubletime){doubleaccount; account=floor(time*price+0.5); if(account>getbalance()) cout<<"你的話費不足,請及時繳費!"<<endl; else record(date,-account);}voidCperson::select(char*name1){for(inti=0;i<n;i++)if(strcmp(name,name1)==0) cout<<"你查找的用戶為"<<name<<endl; else cout<<"你查找的用戶不存在"<<endl;}voidCperson::input(intphonenumber,char*name1,Address&address1,stringpostnumber,doublebalance,doubletime){phonenumber=phonenumber; name=newchar[strlen(name1)+1];//為name申請動態(tài)的內存空間strlen()是查出字符串長度的函數(shù) strcpy(name,name1);//字符串的賦值 address=address1;postnumber=postnumber; balance=balance; time=time;}voidCperson::show()const{cout<<"phonenumber="<<phonenumber<<endl; cout<<"name="<<name<<endl; cout<<"address="<<Address(province,city,street)<<endl; cout<<"postnumber="<<postnumber<<endl; cout<<"balance="<<balance<<endl; cout<<"time="<<time<<endl;}voidCperson::alter(intphonenumber1,char*name1){ Cperson*person;person=newCperson[n]; for(inti=0;i<n;i++) if(person->phonenumber==phonenumber1) cout<<"chae";// name=(*name1); else cout<<"你要修改的用戶不存在!"<<endl;//person=newCperson[n];}voidCperson::insert(intphonenumber){}Cperson::~Cperson(){delete[]name;//釋放動態(tài)內存空間}//Cperson類的測試#include"Address.h"#include"Cperson.h"#include<iostream>#include<fstream>#include<iomanip>#include<string>usingnamespacestd;doubleCperson::price=0.8;unsignedintCperson::n=1;intmain(){ intdate; doubleaccount;intlastdate; intm; intn=1; intphonenumber; charname[20];stringprovince,city,street; stringpostnumber; doublebalance; doubletime; AddressAdd;Cperson*person=newCperson[n];/*Cpersonp(12,23,"韓波","息縣","123"); cout<<"date="<<lastdate<<endl; cout<<"address="<<address<<endl;*/ for(inti=0;i<n;i++) { cout<<"請輸入第"<<i+1<<"個人的信息"<<endl; cout<<"date="; cin>>lastdate; cout<<"phonenumber="; cin>>phonenumber; cout<<"name="; cin>>name;cout<<"province="; cin>>province; cout<<"city="; cin>>city; cout<<"street="; cin>>street; Address.getaddress(province,city,street);cout<<"postnumber="; cin>>postnumber;cout<<"balance="; cin>>balance; cout<<"time="; cin>>time; person[i].input(phonenumber,name,(province,city,street),postnumber,balance,time); for(inti=0;i<n;i++) { cout<<"請輸入第"<<i+1<<"個用戶的姓名,電話號碼,地址,郵政編號"; cin>>person[i].name>>person[i].phonenumber>>person[i].address>>person[i].postnumber; } fstreamMyfile1,Myfile2;Myfile1.open("D:\\用戶信息.txt",ios::out);Myfile1<<"***********用戶信息***********"<<endl<<endl; Myfile1<<"姓名"<<"電話號碼"<<"地址"<<"郵政編碼" <<endl<<"***************************************************************"<<endl;for(i=0;i<n;i++) Myfile1<<"NO."<<setw(2)<<n+1<<""<<setw(6)<<person[i].name<<""<<person[i].phonenumber<<""<<setw(8)<<person[i].address<<""<<person[i].postnumber<<endl;Myfile1.close();cout<<"你輸入的數(shù)據(jù)為:"<<endl; cout<<"date="<<lastdate<<endl; cout<<"phonenumber="<<phonenumber<<endl;cout<<"name="<<name<<endl;cout<<"address="<<Add.getaddress(province,city,street)<<endl;cout<<"postnumber="<<postnumber<<endl;cout<<"balance="<<balance<<endl;cout<<"time="<<time<<endl;} Cpersonperson1; cout<<"********************************************"<<endl; cout<<"你要進行的操作是:"<<endl; cout<<"1:顯示"<<"\t"<<"2:查詢"

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論