Initial commit

This commit is contained in:
Proditio 2021-10-19 06:45:58 +08:00
parent dbe5ae90a9
commit dc0e358c91
50 changed files with 2236 additions and 2 deletions

266
README.md
View File

@ -1,3 +1,265 @@
# address-book-management-system
# 基于C++的通讯录系统的设计与实现
基于C++的通讯录系统的设计与实现
# 一 需求分析
通讯录系统可帮助使用者管理归纳通讯录名单,达到添加,删除,修改,保存等需求。
# 二 系统设计
## 2.1 **功能模块设计**
**通讯录主要功能为:**添加通讯录成员,修改成员,删除成员,按需求搜索查看成员,保存为文档。
如下图所示:
![](http://www.write-bug.com/myres/static/uploads/2021/10/19/bc5ec8765192d2e34a411ca325319160.writebug)
**系统各模块的功能具体描述为:**
**1**、添加成员模块
提供界面让使用者输入希望加入的通讯录成员的各类信息(姓名,电话,住址, QQ邮箱等并检查格式是否有误。若格式无误则将该通讯录信息通过二进制文件方式储存在./contact文件目录下。
**2**、修改成员模块
使用者可以重写已有的通讯录成员,增加或删除除姓名以外的各个信息。一条通 讯录成员可以拥有多个电话号码或QQ。
**3**、删除成员模块
使用者可以选择某个不希望继续使用的通讯录成员并删除他们。
**4**、搜索查看成员模块
使用者通过各种方式查询已添加的通讯录成员,并决定是否修改或删除它们。提供的方法有:精准查询,模糊查询,按分类查询等。
## 2.2 系统架构设计
系统开发使用Template Method设计模式和Strategy Patten 两种设计模式较好的封装所需函数使得主程序入口开发环节只需关注Contact.h头文件即可实现。
具体类之间的耦合关系见下图:
![](http://www.write-bug.com/myres/static/uploads/2021/10/19/a203ff3046cc160d1b971568683ffd63.writebug)
**类的关系设计如下图所示:**
![](http://www.write-bug.com/myres/static/uploads/2021/10/19/db7ed97700697f6e106a4f72e6346ffc.writebug)
**各类的具体功能和说明如下:**
- class Person; 提供基本的数据存储结构
- classContactInterface; 提供主函数菜单策略选择方法。是Contact类的一个接口MainStrategy的调用者
- classContactInit; 提供初始化程序所需函数。同样是Contact类的一个接口
- classContact; 具体实现了两个接口的方法。MainStrategy的决策者。同时面向调用者main.cpp。但注意Contact不提供任何public方法。需要通过两个接口调用
- classCheckInterface; 提供检查函数
- classMainStrategy; Strategy Patten设计模式。同时包含子类公用的方法
- classMainNewMenu; class MainDelMenu; class MainMdfMenu; **分别override **doMainStrategy()函数,实现新建,删除,修改功能
- classMainVewMenuInterface; **override **doMainStrategy()函数ViewStrategy的调用者
- classMainVewMenu; ViewStrategy的决策者
- class ViewStrategy; StrategyPatten
- classViewAllMenu; class ViewExactMenu;
**class ViewFuzzyMenu; class ViewCategoryMenu; **分别override **doViewStrategy()**函数,实现所有查找,精确查找,模糊查找,按类查找功能。
# 三 系统实现
## 3.1 系统实现流程
通讯录系统实现流程如下图所示:
![](http://www.write-bug.com/myres/static/uploads/2021/10/19/5bdb36bb9f84f408f3aff113738b297a.writebug)
## 3.2 类的实现
系统包含Person,Contact, ContactInterface, ContactInit等类具体类结构声明如下
**Person**类:
```c++
class Person
{
Public
char name[MAXNAME];
char sex;
char tel[MAXTEL];
char addr[MAXADDR];
char zip[MAXZIP];
char mail[MAXMAIL];
char qq[MAXQQ];
char category[MAXCTGY];
Person();
~Person();
};
```
**ContactInterface**类:
```c++
class CheckInterface
{
public:
bool check(Person&, const bool _check_repe) const;
bool check_exact(const Person&, const string) const;
virtual ~CheckInterface(){};
private:
vector<string> part_tq(const Person&, const char* const) const;
};
```
**ContactInit**类:
```c++
class ContactInit
{
public:
virtual int refresh() const = 0;
virtual void welcome() const= 0;
virtual ~ContactInit(){};
};
```
**Contact**类:
```c++
class Contact : public ContactInterface, public ContactInit
{
private:
MainStrategy* setMainStrategy(int);
public:
Contact();
~Contact();
int refresh() const;
void welcome() const;
};
```
**MainStrategy**类:
```c++
class MainStrategy : public CheckInterface
{
public:
MainStrategy();
virtual ~MainStrategy();
virtual int doMainStrategy() = 0;
protected:
void printAll() const;
void print_prsn(const Person&, const string, bool) const;
bool delete_prsn(Person&) const;
int modify_prsn(Person&) const; //Way to modify a spefic Person member, with 0->success, -1->fail
};
```
**MainViewMenuInterface**类:
```c++
class MainVewMenuInterface : public MainStrategy
{
public:
private:
ViewStrategy* viewStrategy;
virtual ViewStrategy* setViewStrategy(int) = 0;
virtual int view(Person* v_Person) const;
public:
MainVewMenuInterface();
virtual ~MainVewMenuInterface();
virtual int doMainStrategy();
};
```
# 四 系统测试
## 4.1 登录界面
系统运行开始的界面如图所示:
![](http://www.write-bug.com/myres/static/uploads/2021/10/19/32dbe51ca9ec80a24acaf075328f0d88.writebug)
主要通过选择结构和循环结构实现界面的前进和后退。例如第一个登录界面出现5个选择1.新建2.删除3.修改4.浏览5.退出
## 4.2 添加联系人
在开始界面输入“1”即添加新的成员
![](http://www.write-bug.com/myres/static/uploads/2021/10/19/3daf468c06b3014d605f10ec00365ebe.writebug)
若显示 Information Entry Success! 则录入数据成功。若显示Information Error! 则录入数据失败。如图则因为在电话(TEL)中出现了中文字符。随后将返回主界面。
![](http://www.write-bug.com/myres/static/uploads/2021/10/19/fe23be738be6c25fadf86502f96ea086.writebug)
## 4.3 删除联系人
在主界面输入2可删除成员
![](http://www.write-bug.com/myres/static/uploads/2021/10/19/e6c9d2abdbec776664748b61fbff9f9f.writebug)
如我们希望删除2数据则键入2
![](http://www.write-bug.com/myres/static/uploads/2021/10/19/a9e40e12e21a997342a33c55b0fe34d0.writebug)
就可以得到2的详细数据。输入y/n即可选择是否删除该成员。随后程序将返回主界面。
## 4.4 修改联系人
在主界面下输入3可以修改已有的成员我们希望修改刚刚加入的成员1的电话号码同时加入他所有常用的QQ号码
![](http://www.write-bug.com/myres/static/uploads/2021/10/19/22cda86e3b5dd5bce444b94980e3bc54.writebug)
键入1 可修改第一个人的信息,并按照需求修改信息:
![](http://www.write-bug.com/myres/static/uploads/2021/10/19/c1775a7e9a2c6fccf937f8a0b0858f0d.writebug)
![](http://www.write-bug.com/myres/static/uploads/2021/10/19/68481038dfb78a97894e0f0b21abdf82.writebug)
确认无误后即可修改信息,随后返回主界面。
## 4.4 搜索联系人
输入4即可按需求分类查看搜索成员
![](http://www.write-bug.com/myres/static/uploads/2021/10/19/483615b4dc7d81f9a00b9aa623108fd0.writebug)
键入1进行精准匹配该模式下只匹配名字如输入“严恩伟”后匹配信息如图
![](http://www.write-bug.com/myres/static/uploads/2021/10/19/c6d8d639c5f8e2d9fdc402b98bcabd29.writebug)
随后可以根据自身需求选择1-3选项。此处不再演示。
在view模式下键入2进行模糊匹配该模式匹配名字电话地址。只要出现匹配字符即给与显示。如输入“181”后显示
![](http://www.write-bug.com/myres/static/uploads/2021/10/19/f97505b0dc12dcd8e79ea14b481cbc0f.writebug)
选择1-3即可进入其详细页面。此处不再演示。
在view模式下键入3进行分类category匹配。该模式会列出所有的分类并可根据用户选择的分类进行罗列其中未设置的分类被标记为Unset
![](http://www.write-bug.com/myres/static/uploads/2021/10/19/ecf4c1f266c330014fc34ffbdf9086bf.writebug)
根据提示选择1-2即可进入相应页面。选择0即可退出。
在view模式下键入4进行全局匹配。该模式会列出所有的成员
![](http://www.write-bug.com/myres/static/uploads/2021/10/19/b49f90fdd2d7887d5d1e1251d2001d06.writebug)
在view模式下键入5退出view模式。
在主菜单中键入5退出程序。

Binary file not shown.

145
src/CheckInterface.cpp Normal file
View File

@ -0,0 +1,145 @@
// CheckInterface.cpp: implementation of the CheckInterface class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "CheckInterface.h"
bool CheckInterface::check(Person& person, const bool _check_repe) const {
int i = 0, j = 0; //common loop variable
string re_write = ""; //rewrite tel and qq(if valid) into good format
vector<string> temp_str;
bool mailFlag = false; //check mailbox's format
//===============================
if (!((strlen(person.name)>0) && (strlen(person.tel)>0) && (strlen(person.addr)>0)) ){
errorMsg = "Name/Tel/Address is null.";
return false;
}
//===============================
if (_check_repe){ //here to use _check_repe only once.
for (i = 0; i < contact_item.size(); i++)
if (strcmp(person.name,&*contact_item[i]->name) == 0){
sizeof(*contact_item[i]);
errorMsg = "Item already exists.";
return false;
}
}
//===============================
for (i = 0; i<strlen(person.tel); i++){
if (!(( (person.tel[i]>='0')&&(person.tel[i]<='9') ) || (person.tel[i] == ','))){
errorMsg = "Unknown character in Tel option.";
return false;
}
}
temp_str = this->part_tq(person, "tel");
re_write = "";
for (i = 0; i<temp_str.size(); i++){
for (j = i + 1; j<temp_str.size();j++){
if ((temp_str.at(i) == temp_str.at(j)) && (temp_str.at(i) != "")){
errorMsg = "Duplicated Tel number(s).";
return false;
}
}
if (temp_str.at(i) != ""){
re_write += temp_str.at(i);
re_write += ",";
}
}
re_write = re_write.substr(0,re_write.length()-1);
strcpy(person.tel,re_write.c_str());
//===============================
if (person.sex != '\0'){
if ((person.sex == 'f') || (person.sex == 'm'))
person.sex -=32;
if ( !( (person.sex == 'F') || (person.sex == 'M') ) ){
errorMsg = "Unknown character in Gender option.";
return false;
}
}
//===============================
if (strcmp(person.mail,"") != 0){
mailFlag = false;
for (i = 0; i<strlen(person.mail); ++i){
if (person.mail[i] == '@'){
if (mailFlag){
errorMsg = "Format of Mailbox fill is incorrect.";
return false;
}
(!mailFlag) && (mailFlag = true);
}
}//for
if (!mailFlag){
errorMsg = "Format of Mailbox fill is incorrect.";
return false;
}
}
//===============================
if (strcmp(person.qq, "") != 0){
re_write = "";
for (i = 0; i<strlen(person.qq); i++)
if (!(( (person.qq[i]>='0')&&(person.qq[i]<='9') ) || (person.qq[i] == ','))){
errorMsg = "Unknown character in QQ option.";
return false;
}
temp_str.clear();
temp_str = this->part_tq(person, "qq");
for (i = 0; i<temp_str.size(); i++){
for (j = i + 1; j<temp_str.size();j++){
if (temp_str.at(i) == temp_str.at(j)){
errorMsg = "Duplicated QQ number(s).";
return false;
}
}
if (temp_str.at(i) != ""){
re_write += temp_str.at(i);
re_write += ",";
}
}
re_write = re_write.substr(0,re_write.length()-1);
strcpy(person.qq,re_write.c_str());
}
return true;
//===============================
//...
}
bool CheckInterface::check_exact(const Person& index, const string info_str) const{
if (strcmp(index.name,info_str.c_str()) == 0)
return true;
vector<string> temp_vec = part_tq(index, "tel");
for (int i = 0; i<temp_vec.size(); i++){
if (strcmp(temp_vec.at(i).c_str(),info_str.c_str()) == 0)
return true;
}
return false;
}
vector<string> CheckInterface::part_tq(const Person& person, const char* const TEL_QQ) const {
vector<string> rtn_vec;
string src_str;
string temp_str = "";
if (strcmp(TEL_QQ,"tel") == 0)
src_str = person.tel;
else if (strcmp(TEL_QQ,"qq") == 0)
src_str = person.qq;
else
return rtn_vec;
for (int i = 0; i<strlen(src_str.c_str()); i++){
if (src_str[i] == ','){
rtn_vec.push_back(temp_str);
temp_str = "";
}
else
temp_str += src_str[i];
}
rtn_vec.push_back(temp_str);
return rtn_vec;
}

24
src/CheckInterface.h Normal file
View File

@ -0,0 +1,24 @@
// CheckInterface.h: Frame Gallary
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CHECKINTERFACE_H__ABFADC84_DBE2_4985_9360_97CF317116D0__INCLUDED_)
#define AFX_CHECKINTERFACE_H__ABFADC84_DBE2_4985_9360_97CF317116D0__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Person.h"
class CheckInterface
{
private:
vector<string> part_tq(const Person&, const char* const) const;
public:
virtual ~CheckInterface(){};
bool check(Person&, const bool _check_repe) const;
bool check_exact(const Person&, const string) const; //check if index.name == info_str
};
#endif // !defined(AFX_CHECKINTERFACE_H__ABFADC84_DBE2_4985_9360_97CF317116D0__INCLUDED_)

108
src/Contact.cpp Normal file
View File

@ -0,0 +1,108 @@
#include "stdafx.h"
#include "Contact.h"
extern vector<Person*> contact_item;
extern string errorMsg;
Contact::Contact()
{
MainFunctionsNum = 5;
refresh();
}
Contact::~Contact()
{
int freei = contact_item.size();
for (int i = 0; i<freei; ++i){
delete(contact_item.at(i));
}
}
MainStrategy* Contact::setMainStrategy(int num){
switch (num){
case 1:
return new MainNewMenu();
case 2:
return new MainDelMenu();
case 3:
return new MainMdfMenu();
case 4:
return new MainVewMenu();
case 5:
return NULL;
}
return NULL;
}
void Contact::removeMainStrategy(void* p){
delete p;
}
void Contact::welcome() const{
int n = 0;
system("cls");
cout<<"\n\n\n----------Welcome to the Address Book System.--------\n\n";
cout<<"-----now LOADING address book...";
n = refresh();
Sleep(800);
if (n > 0){
cout<<"\t"<<n<<" contact(s) have been imported.\n";
}
else if (n == -1){
cout<<"\tFolder contact does not exist!.Please retry later!\n";
getch();
exit(0);
}
else{
cout<<"\t"<<"no contact has been imported.\n";
}
Sleep(50);
cout<<" Login...";
Sleep(300);
cout<<" Successful!";
Sleep(40);
}
int Contact::refresh() const{
string info_check;
contact_item.clear();
long hFile = 0;
struct _finddata_t fileinfo;
const char* cp = ".\\contact\\*";
const char* dir = ".\\contact";
int freei = contact_item.size();
for (int i = 0; i<freei; ++i){
delete(contact_item.at(i));
}
if ((hFile = _findfirst(cp, &fileinfo)) != -1){
do{
if (!(fileinfo.attrib & _A_SUBDIR)){
string path = ".\\contact\\";
path += fileinfo.name;
Person *temp_p = new Person;
FILE* fp = fopen(path.c_str(), "rb");
fread(temp_p, sizeof(*temp_p), 1, fp);
fclose(fp);
info_check = temp_p->name;
info_check += ".ctt";
if (info_check == fileinfo.name)
contact_item.push_back(temp_p);
}
} while (_findnext(hFile, &fileinfo) == 0);
_findclose(hFile);
}
else{
if (!CreateDirectory(dir, NULL)) return -1;
}
return contact_item.size();
}

33
src/Contact.h Normal file
View File

@ -0,0 +1,33 @@
// Contact.h: Application Library
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_Contact_H__578FBE4B_85A0_4A32_B651_7CF4D553E488__INCLUDED_)
#define AFX_Contact_H__578FBE4B_85A0_4A32_B651_7CF4D553E488__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "ContactInterface.h"
#include "ContactInit.h"
#include "MainNewMenu.h"
#include "MainDelMenu.h"
#include "MainMdfMenu.h"
#include "MainVewMenu.h"
class Contact : public ContactInterface, public ContactInit
{
private:
MainStrategy* setMainStrategy(int); //override from ContactInterface
void removeMainStrategy(void*); //...
int refresh() const; //override from ContactInit
void welcome() const; //...
public:
Contact();
~Contact();
};
#endif // !defined(AFX_Contact_H__578FBE4B_85A0_4A32_B651_7CF4D553E488__INCLUDED_)

20
src/ContactInit.h Normal file
View File

@ -0,0 +1,20 @@
// ContactInit.h: Frame Gallary
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CONTACTINIT_H__5C8BC83A_4BE8_4C6A_A36F_6CF4CC06AA7B__INCLUDED_)
#define AFX_CONTACTINIT_H__5C8BC83A_4BE8_4C6A_A36F_6CF4CC06AA7B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class ContactInit
{
public:
virtual ~ContactInit(){};
virtual int refresh() const = 0;
virtual void welcome() const= 0;
};
#endif // !defined(AFX_CONTACTINIT_H__5C8BC83A_4BE8_4C6A_A36F_6CF4CC06AA7B__INCLUDED_)

32
src/ContactInterface.cpp Normal file
View File

@ -0,0 +1,32 @@
#include "stdafx.h"
#include "ContactInterface.h"
extern vector<Person*> contact_item;
extern string errorMsg;
int ContactInterface::main_menu(){
char rtn_int;
int fuckin_stupid = 0;
cin.clear();
cin.sync();
do{
system("cls");
readFile(".\\io\\MainMenu.io");
if (fuckin_stupid != 0)
cout<<"\t\tError Inputing!\n";
cout<<"\tEnter number[1-"<<MainFunctionsNum<<"] to select the corresponding function: ";
cin.clear();
cin.sync();
rtn_int = getch();
fuckin_stupid++;
}while((rtn_int<'1') || (rtn_int>'0' + MainFunctionsNum));
mainStrategy = setMainStrategy(rtn_int-'0');
if (mainStrategy == NULL){
return -1;
}
mainStrategy->doMainStrategy();
removeMainStrategy(mainStrategy);
return 0;
}

29
src/ContactInterface.h Normal file
View File

@ -0,0 +1,29 @@
// ContactInterface.h: Frame Gallary
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CONTACTINTERFACE_H__61397655_84DB_48A0_A5E4_041E75321807__INCLUDED_)
#define AFX_CONTACTINTERFACE_H__61397655_84DB_48A0_A5E4_041E75321807__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "MainStrategy.h"
#include "CheckInterface.h"
#include "PrtMenuInterface.h"
class ContactInterface : public PrtMenuInterface
{
private:
MainStrategy* mainStrategy;
virtual MainStrategy* setMainStrategy(int) = 0;
virtual void removeMainStrategy(void*) = 0;
protected:
int MainFunctionsNum;
public:
int main_menu();
virtual ~ContactInterface(){};
};
#endif // !defined(AFX_CONTACTINTERFACE_H__61397655_84DB_48A0_A5E4_041E75321807__INCLUDED_)

41
src/MainDelMenu.cpp Normal file
View File

@ -0,0 +1,41 @@
// MainDelMenu.cpp: implementation of the MainDelMenu class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MainDelMenu.h"
MainDelMenu::doMainStrategy()
{
int num = contact_item.size();
int index = 0;
string addr = ".\\contact\\";
system("cls");
cout<<endl;
cout<<"=====Delete Contact====================\n\n";
if (num > 1){
printAll();
cout<<"\n\tEnter the INDEX(1 - "<<num<<") of the information you want to DELETE:(0 for quit) ";
cin.clear();
cin.sync();
cin>>index;
if ((index<0) || (index>num)){
cout<<"\n\n\t\tError Input!\n";
cin.clear();
cin.sync();
getch();
index = 0;
}
}
else if ( num == 1)
index = 1;
if (index == 0)
return 0;
index--;
print_prsn(*contact_item[index],"=====Delete Contact====================\n",true);
delete_prsn(*contact_item[index]);
cin.clear();
cin.sync();
getchar();
return 0;
}

21
src/MainDelMenu.h Normal file
View File

@ -0,0 +1,21 @@
// MainDelMenu.h: Application Library
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINDELMENU_H__59F8280E_220C_4D11_9B6E_96B22BB96034__INCLUDED_)
#define AFX_MAINDELMENU_H__59F8280E_220C_4D11_9B6E_96B22BB96034__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "MainStrategy.h"
class MainDelMenu : public MainStrategy
{
public:
virtual ~MainDelMenu(){};
int doMainStrategy();
};
#endif // !defined(AFX_MAINDELMENU_H__59F8280E_220C_4D11_9B6E_96B22BB96034__INCLUDED_)

41
src/MainMdfMenu.cpp Normal file
View File

@ -0,0 +1,41 @@
// MainMdfMenu.cpp: implementation of the MainMdfMenu class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MainMdfMenu.h"
MainMdfMenu::doMainStrategy()
{
int num = contact_item.size();
int index = 0;
system("cls");
cout<<endl;
cout<<"=====Modify Contact====================\n\n";
if (num > 1){
printAll();
cout<<"\n\tEnter the INDEX(1 - "<<num<<") of the information you want to MODIFY:(0 for quit) ";
cin.clear();
cin.sync();
cin>>index;
if ( (index<0) || (index>num) ){
cout<<"\n\t\tError Input!\n";
cin.clear();
cin.sync();
getch();
index = 0;
}
}
else if ( num == 1)
index = 1;
if (index == 0)
return 0;
index--;
modify_prsn(*contact_item.at(index));
cin.clear();
cin.sync();
getch();
return 0;
}

21
src/MainMdfMenu.h Normal file
View File

@ -0,0 +1,21 @@
// MainMdfMenu.h: Application Library
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINMDFMENU_H__4AF95322_636F_4CB7_B574_C8FB878AFB87__INCLUDED_)
#define AFX_MAINMDFMENU_H__4AF95322_636F_4CB7_B574_C8FB878AFB87__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "MainStrategy.h"
class MainMdfMenu : public MainStrategy
{
public:
virtual ~MainMdfMenu(){};
int doMainStrategy();
};
#endif // !defined(AFX_MAINMDFMENU_H__4AF95322_636F_4CB7_B574_C8FB878AFB87__INCLUDED_)

107
src/MainNewMenu.cpp Normal file
View File

@ -0,0 +1,107 @@
// MainNewMenu.cpp: implementation of the MainNewMenu class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MainNewMenu.h"
MainNewMenu::doMainStrategy()
{
system("cls");
cout<<endl;
cout<<"=====New Contact====================\n\n";
if(!create())
cout<<"\n\n\t\tInfomation Error!";
else
cout<<"\n\n\t\tInfomation Entry Success!";
cin.clear();
cin.sync();
getchar();
return 0;
}
bool MainNewMenu::create() const{
Person t_info;
string t_str = "";
cout<<"You can use ',[en]'(NOT '£¬[chs]') to enter more than one data(Only for *Tel and *QQ)"<<endl<<endl;
cout<<"Name:";
cin.clear();
cin.sync();
cin>>t_info.name;
cout<<"Address:";
cin.clear();
cin.sync();
cin>>t_info.addr;
cout<<"*Tel:";
cin.clear();
cin.sync();
cin>>t_info.tel;
char t_c;
cout<<"\n\tthe following data can be set as NULL.Press ENTER to skip\n\n";
cin.clear();
cin.sync();
cout<<"Gender:(M for Male, F for Female)";
char _c= getchar();
if (_c != '\n')
t_info.sex = _c;
cin.clear();
cin.sync();
cout<<"Zip:";
while((t_c = getchar()) != '\n'){
t_str += t_c;
}
strcpy(t_info.zip,t_str.c_str());
cin.clear();
cin.sync();
t_str = "";
cout<<"Mailbox:";
while((t_c = getchar()) != '\n'){
t_str += t_c;
}
strcpy(t_info.mail,t_str.c_str());
cin.clear();
cin.sync();
t_str = "";
cout<<"*QQ:";
while((t_c = getchar()) != '\n'){
t_str += t_c;
}
strcpy(t_info.qq, t_str.c_str());
cin.clear();
cin.sync();
t_str = "";
cout<<"Category:";
while((t_c = getchar()) != '\n'){
t_str += t_c;
}
strcpy(t_info.category,t_str.c_str());
cin.clear();
cin.sync();
t_str = "";
if(!check(t_info, true) ){
cout<<"\n\t\t"<<errorMsg<<endl;
return false;
}
//--------------------------------------------------------
char _char[30] = "";
char* t_addr = _char;
sprintf(t_addr,".\\contact\\%s.ctt",t_info.name);
FILE* fp = fopen(t_addr ,"wb+");
if(fwrite(&t_info, sizeof(t_info), 1, fp) != 1)
printf("err");
fclose(fp);
//--------------------------------------------------------
return true;
}

23
src/MainNewMenu.h Normal file
View File

@ -0,0 +1,23 @@
// MainNewMenu.h: Application Library
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINNEWMENU_H__FAE001ED_B300_4102_8F33_09E79DFDAEA6__INCLUDED_)
#define AFX_MAINNEWMENU_H__FAE001ED_B300_4102_8F33_09E79DFDAEA6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "MainStrategy.h"
class MainNewMenu : public MainStrategy
{
private:
bool create() const;
public:
virtual ~MainNewMenu(){};
int doMainStrategy();
};
#endif // !defined(AFX_MAINNEWMENU_H__FAE001ED_B300_4102_8F33_09E79DFDAEA6__INCLUDED_)

184
src/MainStrategy.cpp Normal file
View File

@ -0,0 +1,184 @@
// MainStrategy.cpp: implementation of the MainStrategy class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MainStrategy.h"
void MainStrategy::print_prsn(const Person& prt_Person, const string info, bool refresh) const{
system("cls");
cout<<endl<<info;
if(refresh) Sleep(20);
cout<<"\n\tName: "<<prt_Person.name;
if(refresh) Sleep(20);
cout<<"\n\tTel: "<<prt_Person.tel;
if(refresh) Sleep(20);
cout<<"\n\tAddress: "<<prt_Person.addr;
if(refresh) Sleep(20);
cout<<"\n\tGendle: "<<prt_Person.sex ;
if(refresh) Sleep(20);
cout<<"\n\tZip: "<<prt_Person.zip;
if(refresh) Sleep(20);
cout<<"\n\tMail: "<<prt_Person.mail;
if(refresh) Sleep(20);
cout<<"\n\tQQ: "<<prt_Person.qq;
if(refresh) Sleep(20);
cout<<"\n\tCategory: "<<prt_Person.category;
if(refresh) Sleep(20);
}
void MainStrategy::printAll() const{
int num = contact_item.size();
for (int i = 0; i < num; i++){
cout<<"("<<i+1<<"): "<<&*contact_item[i]->name<<" TEL: "<<&*contact_item[i]->tel<<" ADDR: "<<&*contact_item[i]->addr<<endl;
Sleep(20);
}
}
bool MainStrategy::delete_prsn(Person& del_Person) const{
char y_n;
string addr = ".\\contact\\";
cout<<"\n\n\t\tReally want to delete?[y/n]: ";
cin.clear();
cin.sync();
y_n = getch();
if ((y_n == 'y') || (y_n == 'Y')){
addr += del_Person.name;
addr += ".ctt";
if (remove(addr.c_str())){
cout<<"\n\t\tError removing data!\n";
return false;
}
cout<<"\n\t\tDelete Successful!\n";
return true;
}
else
cout<<"\n\t\tCanceled!\n";
return false;
}
bool MainStrategy::modify_prsn(Person& m_Person) const{
char t_c;
char y_n;
string addr = ".\\contact\\";
string t_str = "";
addr += m_Person.name;
addr += ".ctt";
Person t_info = m_Person;
system("cls");
cout<<endl<<"=====Modify Contact====================(Enter a new value at the cursor.ENTER to SKIP.)\n";
cout<<"\n When you entering Tel and QQ information, you can input '+' at the beginning to add the data to the end of the existing data.\n I will remind you later.(*)\n";
cout<<"\n\tName: "<<m_Person.name;
cout<<"\n\t*Tel: "<<m_Person.tel<<"\t:(eg:+12345) ";
cin.clear();cin.sync();
t_str = "";
while((t_c = getchar()) != '\n')
{t_str += t_c;}
if (t_str[0] == '+'){
t_str.erase(&t_str[0]);
string _t_str = t_info.tel;
_t_str += ",";
_t_str += t_str;
t_str = _t_str;
strcpy(t_info.tel,t_str.c_str());
}
else{
if (t_str != "") strcpy(t_info.tel,t_str.c_str());
if (t_str == " ") strcpy(t_info.tel,"");
}
cout<<"\tAddress: "<<m_Person.addr<<"\t: ";
cin.clear();cin.sync();
t_str = "";
while((t_c = getchar()) != '\n')
{t_str += t_c;}
if (t_str != "") strcpy(t_info.addr,t_str.c_str());
if (t_str == " ") strcpy(t_info.addr,"");
cout<<"\tGendle: "<<m_Person.sex <<"\t: ";
cin.clear();cin.sync();
t_c= getchar();
if (t_c != '\n')
t_info.sex = t_c;
if (t_c == ' ')
t_info.sex = '\0';
cout<<"\tZip: "<<m_Person.zip<<"\t: ";
cin.clear();cin.sync();
t_str = "";
while((t_c = getchar()) != '\n')
{t_str += t_c;}
if (t_str != "") strcpy(t_info.zip,t_str.c_str());
if (t_str == " ") strcpy(t_info.zip,"");
cout<<"\tMail: "<<m_Person.mail<<"\t: ";
cin.clear();cin.sync();
t_str = "";
while((t_c = getchar()) != '\n')
{t_str += t_c;}
if (t_str != "") strcpy(t_info.mail,t_str.c_str());
if (t_str == " ") strcpy(t_info.mail,"");
cout<<"\t*QQ: "<<m_Person.qq<<"\t:(eg:+12345) ";
cin.clear();cin.sync();
t_str = "";
while((t_c = getchar()) != '\n')
{t_str += t_c;}
if (t_str[0] == '+'){
t_str.erase(&t_str[0]);
string _t_str = t_info.qq;
_t_str += ",";
_t_str += t_str;
t_str = _t_str;
strcpy(t_info.qq,t_str.c_str());
}
else{
if (t_str != "") strcpy(t_info.qq,t_str.c_str());
if (t_str == " ") strcpy(t_info.qq,"");
}
cout<<"\tCategory: "<<m_Person.category<<"\t: ";
cin.clear();cin.sync();
t_str = "";
while((t_c = getchar()) != '\n')
{t_str += t_c;}
if (t_str != "") strcpy(t_info.category,t_str.c_str());
if (t_str == " ") strcpy(t_info.category,"");
this->print_prsn(t_info,"=====Modify Contact====================\n",true);
cout<<"\n\n\t\tReally want to modify?[y/n]: ";
cin.clear();
cin.sync();
y_n = getch();
if ((y_n == 'y') || (y_n == 'Y')){
if(!check(t_info, false) ){
cout<<"\n\t\tInfomation Error!";
return false;
}
else{
FILE *fp = fopen(addr.c_str(),"wb+");
if (fp == NULL ){
cout<<"\n\t\tError opening file!\n";
return false;
}
else
if (fwrite(&t_info,sizeof(Person), 1, fp) != 1){
cout<<"\n\t\tError writing to file!\n";
return false;
}
else{
cout<<"\n\t\tModify succeed!\n";
fclose(fp);
}
}
}
else
cout<<"\n\t\tCanceled!\n";
return true;
}

28
src/MainStrategy.h Normal file
View File

@ -0,0 +1,28 @@
// MainStrategy.h: Frame Gallary
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINSTRATEGY_H__EC9C2730_7A1B_40AF_AB90_CC8AC25EC1B5__INCLUDED_)
#define AFX_MAINSTRATEGY_H__EC9C2730_7A1B_40AF_AB90_CC8AC25EC1B5__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "CheckInterface.h"
class MainStrategy : public CheckInterface
{
public:
virtual ~MainStrategy(){};
virtual int doMainStrategy() = 0;
protected:
void printAll() const;
void print_prsn(const Person&, const string, bool) const;
bool delete_prsn(Person&) const;
bool modify_prsn(Person&) const; //Way to modify a spefic Person member
};
//extern vector<Person*> contact_item;
#endif // !defined(AFX_MAINSTRATEGY_H__EC9C2730_7A1B_40AF_AB90_CC8AC25EC1B5__INCLUDED_)

20
src/MainTestMenu.cpp Normal file
View File

@ -0,0 +1,20 @@
// MainTestMenu.cpp: implementation of the MainTestMenu class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MainTestMenu.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
MainTestMenu::MainTestMenu()
{
}
MainTestMenu::~MainTestMenu()
{
}

26
src/MainTestMenu.h Normal file
View File

@ -0,0 +1,26 @@
// MainTestMenu.h: interface for the MainTestMenu class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINTESTMENU_H__4F0A9680_D41C_411A_B456_680B37EB8308__INCLUDED_)
#define AFX_MAINTESTMENU_H__4F0A9680_D41C_411A_B456_680B37EB8308__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "MainStrategy.h"
class MainTestMenu : public MainStrategy
{
public:
MainTestMenu();
virtual ~MainTestMenu();
virtual int doMainStrategy(){
cout<<"test!\n";
getch();
return 0;
}
};
#endif // !defined(AFX_MAINTESTMENU_H__4F0A9680_D41C_411A_B456_680B37EB8308__INCLUDED_)

32
src/MainVewMenu.cpp Normal file
View File

@ -0,0 +1,32 @@
// MainVewMenu.cpp: implementation of the MainVewMenu class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MainVewMenu.h"
MainVewMenu::MainVewMenu(){
ViewFunctionsNum = 5;
}
ViewStrategy* MainVewMenu::setViewStrategy(int slct_num){
switch(slct_num){
case 1:
return new ViewExactMenu();
case 2:
return new ViewFuzzyMenu();
case 3:
return new ViewCategoryMenu();
case 4:
return new ViewAllMenu();
case 5:
break;
}
return NULL;
}
void MainVewMenu::removeViewStrategy(void* p){
delete p;
}

29
src/MainVewMenu.h Normal file
View File

@ -0,0 +1,29 @@
// MainVewMenu.h: Application Library
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINVEWMENU_H__30EDC353_618B_4196_A8BB_4A59557068CD__INCLUDED_)
#define AFX_MAINVEWMENU_H__30EDC353_618B_4196_A8BB_4A59557068CD__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "MainVewMenuInterface.h"
#include "ViewExactMenu.h"
#include "ViewAllMenu.h"
#include "ViewCategoryMenu.h"
#include "ViewFuzzyMenu.h"
class MainVewMenu : public MainVewMenuInterface
{
private:
ViewStrategy* setViewStrategy(int);
void removeViewStrategy(void*);
public:
MainVewMenu();
virtual ~MainVewMenu(){};
};
#endif // !defined(AFX_MAINVEWMENU_H__30EDC353_618B_4196_A8BB_4A59557068CD__INCLUDED_)

View File

@ -0,0 +1,84 @@
// MainVewMenuInterface.cpp: implementation of the MainVewMenuInterface class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MainVewMenuInterface.h"
void sleep(){
Sleep(20);
return;
}
int MainVewMenuInterface::view(Person* v_Person) const{
if (v_Person == NULL)
return -1;
bool refresh = true;
string addr = ".\\contact\\";
int fuckin_stupid = 0;
int slct_num = 0;
do{
print_prsn(*v_Person,"=====VIEW Contact====================\n",refresh);
if (refresh){
readFile(".\\io\\View.io",sleep);
}
else{
readFile(".\\io\\View.io");
}
cin.clear();
cin.sync();
if (fuckin_stupid != 0)
cout<<"\t\tError Inputing!\n";
cout<<"\tEnter number[1-3] to select the corresponding function: ";
cin.clear();
cin.sync();
slct_num = getch();
fuckin_stupid++;
refresh = false;
}while((slct_num<'1') || (slct_num>'3'));
switch (slct_num){
case '1':
delete_prsn(*v_Person);
cin.clear();
cin.sync();
getch();
break;
case '2':
modify_prsn(*v_Person);
cin.clear();
cin.sync();
getch();
break;
case '3':
break;
}
return 0;
}
int MainVewMenuInterface::doMainStrategy()
{
int fuckin_stupid = 0;
char slct_num = 0;
do{
system("cls");
readFile(".\\io\\ViewMenu.io");
if (fuckin_stupid != 0)
cout<<"\t\tError Inputing!\n";
cout<<"\tEnter number[1-"<<ViewFunctionsNum<<"] to select the corresponding function: ";
cin.clear();
cin.sync();
slct_num = getch();
fuckin_stupid++;
}while((slct_num<'1') || (slct_num>'0' + ViewFunctionsNum));
viewStrategy = setViewStrategy(slct_num - '0');
if (viewStrategy == NULL)
return -1;
view(viewStrategy->doViewStrategy());
removeViewStrategy(viewStrategy);
return 0;
}

View File

@ -0,0 +1,31 @@
// MainVewMenuInterface.h: Frame Gallary
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINVEWMENUINTERFACE_H__7A32F346_890E_45E1_941B_4FC6A6A3714A__INCLUDED_)
#define AFX_MAINVEWMENUINTERFACE_H__7A32F346_890E_45E1_941B_4FC6A6A3714A__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "MainStrategy.h"
#include "ViewStrategy.h"
#include "PrtMenuInterface.h"
class MainVewMenuInterface : public MainStrategy, public PrtMenuInterface
{
private:
ViewStrategy* viewStrategy;
virtual int view(Person* v_Person) const; //View a Person member with details
virtual ViewStrategy* setViewStrategy(int) = 0;
virtual void removeViewStrategy(void*) = 0;
protected:
int ViewFunctionsNum;
public:
virtual ~MainVewMenuInterface(){};
int doMainStrategy();
};
#endif // !defined(AFX_MAINVEWMENUINTERFACE_H__7A32F346_890E_45E1_941B_4FC6A6A3714A__INCLUDED_)

19
src/Person.cpp Normal file
View File

@ -0,0 +1,19 @@
#include "stdafx.h"
#include "Person.h"
Person::Person()
{
strcpy(this->addr,"");
strcpy(this->category,"");
strcpy(this->mail, "");
strcpy(this->name, "");
strcpy(this->qq, "");
this->sex = '\0';
strcpy(this->tel, "");
strcpy(this->zip, "");
}
Person::~Person()
{
}

38
src/Person.h Normal file
View File

@ -0,0 +1,38 @@
// Person.h: Frame Gallary
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_Person_H__4EDC1B44_F6DC_404A_ADA9_E56095080841__INCLUDED_)
#define AFX_Person_H__4EDC1B44_F6DC_404A_ADA9_E56095080841__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define MAXNAME 100
#define MAXTEL 80
#define MAXADDR 100
#define MAXZIP 10
#define MAXMAIL 80
#define MAXQQ 40
#define MAXCTGY 20
class Person
{
public:
Person();
~Person();
char name[MAXNAME];
char sex;
char tel[MAXTEL];
char addr[MAXADDR];
char zip[MAXZIP];
char mail[MAXMAIL];
char qq[MAXQQ];
char category[MAXCTGY];
};
extern vector<Person*> contact_item;
extern string errorMsg;
#endif // !defined(AFX_Person_H__4EDC1B44_F6DC_404A_ADA9_E56095080841__INCLUDED_)

25
src/PrtMenuInterface.cpp Normal file
View File

@ -0,0 +1,25 @@
// PrtMenuInterface.cpp: implementation of the PrtMenuInterface class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "PrtMenuInterface.h"
bool PrtMenuInterface::readFile(const char* file, void(*events)()) const{
char line[1024];
memset(line, 0, 1024);
FILE* fp = fopen(file,"r");
if (fp == NULL){
return false;
}
while(!feof(fp)){
fgets(line, 1024, fp);
cout<<line;
strcpy(line, "");
if (events != NULL){
events();
}
}
fclose(fp);
return true;
}

20
src/PrtMenuInterface.h Normal file
View File

@ -0,0 +1,20 @@
// PrtMenuInterface.h: Frame Gallary
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_PRTMENUINTERFACE_H__77F54599_9711_43E8_97E8_278F62DD0880__INCLUDED_)
#define AFX_PRTMENUINTERFACE_H__77F54599_9711_43E8_97E8_278F62DD0880__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class PrtMenuInterface
{
protected:
virtual bool readFile(const char*, void(*)() = NULL) const;
public:
virtual ~PrtMenuInterface(){};
};
#endif // !defined(AFX_PRTMENUINTERFACE_H__77F54599_9711_43E8_97E8_278F62DD0880__INCLUDED_)

10
src/StdAfx.cpp Normal file
View File

@ -0,0 +1,10 @@
// stdafx.cpp : source file that includes just the standard includes
// contacts.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
#include "Contact.h"
#include "Person.h"
vector<Person*> contact_item;
string errorMsg;

25
src/StdAfx.h Normal file
View File

@ -0,0 +1,25 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__F5925CEB_85C9_4293_8D63_288D374D3EDC__INCLUDED_)
#define AFX_STDAFX_H__F5925CEB_85C9_4293_8D63_288D374D3EDC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#pragma warning(disable:4786)
#include <io.h>
#include <windows.h>
#include <string>
#include <vector>
#include <map>
#include <iostream>
#include <conio.h>
using namespace std;
#endif // !defined(AFX_STDAFX_H__F5925CEB_85C9_4293_8D63_288D374D3EDC__INCLUDED_)

21
src/ViewAllMenu.cpp Normal file
View File

@ -0,0 +1,21 @@
// ViewAllMenu.cpp: implementation of the ViewAllMenu class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ViewAllMenu.h"
Person* ViewAllMenu::doViewStrategy(){
int num = contact_item.size();
int index = 0;
vector<int> chosen_item;
ViewStrategy::all_vew();
for (int i = 0;i<num;i++){
chosen_item.push_back(i);
cout<<"("<<chosen_item.size()<<"): "<<&*contact_item[i]->name<<" TEL: "<<&*contact_item[i]->tel<<" ADDR: "<<&*contact_item[i]->addr<<endl;
Sleep(20);
}
return anythingView(chosen_item);
}

21
src/ViewAllMenu.h Normal file
View File

@ -0,0 +1,21 @@
// ViewAllMenu.h: Application Library
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_VIEWALLMENU_H__8C79467E_E8F5_483F_8EBE_66DD4CE77A44__INCLUDED_)
#define AFX_VIEWALLMENU_H__8C79467E_E8F5_483F_8EBE_66DD4CE77A44__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "ViewStrategy.h"
class ViewAllMenu : public ViewStrategy
{
public:
virtual ~ViewAllMenu(){};
Person* doViewStrategy();
};
#endif // !defined(AFX_VIEWALLMENU_H__8C79467E_E8F5_483F_8EBE_66DD4CE77A44__INCLUDED_)

22
src/ViewCategoryMenu.cpp Normal file
View File

@ -0,0 +1,22 @@
// ViewCategoryMenu.cpp: implementation of the ViewCategoryMenu class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ViewCategoryMenu.h"
Person* ViewCategoryMenu::doViewStrategy(){
string info_str = ViewStrategy::category_vew();
int num = contact_item.size();
int index = 0;
vector<int> chosen_item;
for (int i = 0; i < num; i++){
if (strcmp(&*contact_item[i]->category,info_str.c_str()) == 0 ){
chosen_item.push_back(i);
cout<<"("<<chosen_item.size()<<"): "<<&*contact_item[i]->name<<" TEL: "<<&*contact_item[i]->tel<<" ADDR: "<<&*contact_item[i]->addr<<endl;
Sleep(20);
}
}
return anythingView(chosen_item);
}

21
src/ViewCategoryMenu.h Normal file
View File

@ -0,0 +1,21 @@
// ViewCategoryMenu.h: Application Library
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_VIEWCATEGORYMENU_H__48B023E6_1B4C_4082_A1E2_BB55EEC3B766__INCLUDED_)
#define AFX_VIEWCATEGORYMENU_H__48B023E6_1B4C_4082_A1E2_BB55EEC3B766__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "ViewStrategy.h"
class ViewCategoryMenu : public ViewStrategy
{
public:
virtual ~ViewCategoryMenu(){};
Person* doViewStrategy();
};
#endif // !defined(AFX_VIEWCATEGORYMENU_H__48B023E6_1B4C_4082_A1E2_BB55EEC3B766__INCLUDED_)

22
src/ViewExactMenu.cpp Normal file
View File

@ -0,0 +1,22 @@
// ViewExactMenu.cpp: implementation of the ViewExactMenu class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ViewExactMenu.h"
Person* ViewExactMenu::doViewStrategy(){
string info_str = ViewStrategy::title_vew("=====Exact Query Contact===============", "\tEnter infomation that needs to be querying: ");
int num = contact_item.size();
int index = 0;
vector<int> chosen_item;
for (int i = 0; i < num; i++){
if ( check_exact(*contact_item[i], info_str)){
chosen_item.push_back(i);
cout<<"("<<chosen_item.size()<<"): "<<&*contact_item[i]->name<<" TEL: "<<&*contact_item[i]->tel<<" ADDR: "<<&*contact_item[i]->addr<<endl;
Sleep(20);
}
}
return anythingView(chosen_item);
}

21
src/ViewExactMenu.h Normal file
View File

@ -0,0 +1,21 @@
// ViewExactMenu.h: Application Library
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_VIEWEXACTMENU_H__33A9D84C_B321_4F0C_A59B_3777BF3AE004__INCLUDED_)
#define AFX_VIEWEXACTMENU_H__33A9D84C_B321_4F0C_A59B_3777BF3AE004__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "ViewStrategy.h"
class ViewExactMenu : public ViewStrategy
{
public:
virtual ~ViewExactMenu(){};
Person* doViewStrategy();
};
#endif // !defined(AFX_VIEWEXACTMENU_H__33A9D84C_B321_4F0C_A59B_3777BF3AE004__INCLUDED_)

22
src/ViewFuzzyMenu.cpp Normal file
View File

@ -0,0 +1,22 @@
// ViewFuzzyMenu.cpp: implementation of the ViewFuzzyMenu class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ViewFuzzyMenu.h"
Person* ViewFuzzyMenu::doViewStrategy(){
string info_str = ViewStrategy::title_vew("=====Fuzzy Query Contact===============", "\tEnter infomation that needs to be querying: ");
int num = contact_item.size();
int index = 0;
vector<int> chosen_item;
for (int i = 0; i < num; i++){
if ((strstr(&*contact_item[i]->addr,info_str.c_str()) != NULL) || (strstr(&*contact_item[i]->name ,info_str.c_str()) != NULL) || (strstr(&*contact_item[i]->tel ,info_str.c_str()) != NULL) ) {
chosen_item.push_back(i);
cout<<"("<<chosen_item.size()<<"): "<<&*contact_item[i]->name<<" TEL: "<<&*contact_item[i]->tel<<" ADDR: "<<&*contact_item[i]->addr<<endl;
Sleep(20);
}
}
return anythingView(chosen_item);
}

21
src/ViewFuzzyMenu.h Normal file
View File

@ -0,0 +1,21 @@
// ViewFuzzyMenu.h: Application Library
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_VIEWFUZZYMENU_H__D10D5C93_EEF6_40EA_AEBB_C289EE09C1EF__INCLUDED_)
#define AFX_VIEWFUZZYMENU_H__D10D5C93_EEF6_40EA_AEBB_C289EE09C1EF__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "ViewStrategy.h"
class ViewFuzzyMenu : public ViewStrategy
{
public:
virtual ~ViewFuzzyMenu(){};
Person* doViewStrategy();
};
#endif // !defined(AFX_VIEWFUZZYMENU_H__D10D5C93_EEF6_40EA_AEBB_C289EE09C1EF__INCLUDED_)

103
src/ViewStrategy.cpp Normal file
View File

@ -0,0 +1,103 @@
// ViewStrategy.cpp: implementation of the ViewStrategy class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ViewStrategy.h"
string ViewStrategy::title_vew(const char* title, const char* descp) const{
string info_str;
Person* viewPerson = NULL;
system("cls");
cout<<endl;
cout<<title<<endl<<endl;
cout<<descp;
cin.clear();
cin.sync();
cin>>info_str;
cout<<endl;
return info_str;
}
Person* ViewStrategy::anythingView(vector<int>& chosen_item) const{
int index = 0;
if (chosen_item.size() == 0){
cout<<"\n\t\tNo Item Found!\n";
cin.clear();
cin.sync();
getch();
return NULL;
}
else {
if (chosen_item.size() == 1){
Sleep(400);
index = 1;
}
else{
cout<<"\n\tEnter the INDEX(1 - "<<chosen_item.size()<<") of the information you want to VIEW:(0 for quit) ";
cin.clear();
cin.sync();
cin>>index;
if ((index<0) || (index>chosen_item.size())){
return NULL;
}
}//if (chosen_item.size() == 1)
if (index > 0){
return contact_item.at(chosen_item.at(index-1));
}
return NULL;
}//if (chosen_item.size() == 0)
}
void ViewStrategy::all_vew() const{
int i = 0,j = 0;
Person* viewPerson = NULL;
system("cls");
cout<<endl;
cout<<"=====ALL Category======================\n\n";
return;
}
string ViewStrategy::category_vew() const{
string info_str;
vector<string> cur_ctg;
string tmp_ctg;
bool add_ctg;
int index = 0;
int i = 0,j = 0;
system("cls");
cout<<endl;
cout<<"=====List by Category==================\n\n";
cout<<"\tCurrent category:";
for (i = 0; i<contact_item.size();i++){
tmp_ctg = &*contact_item[i]->category;
if (tmp_ctg == "")
tmp_ctg = "Unset";
add_ctg = true;
for (j = 0; j<cur_ctg.size();j++){
if (cur_ctg[j] == tmp_ctg)
add_ctg = false;
}
if (add_ctg){
cur_ctg.push_back(tmp_ctg);
cout<<" "<<tmp_ctg;
}
}
cout<<"\n\n\tEnter category infomation:";
cin.clear();
cin.sync();
cin>>info_str;
if ((info_str == "Unset") || (info_str == "unset"))
info_str = "";
cout<<endl;
return info_str;
}

26
src/ViewStrategy.h Normal file
View File

@ -0,0 +1,26 @@
// ViewStrategy.h: Frame Gallary
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_VIEWSTRATEGY_H__EC4D2837_CB82_4C72_90B0_0F5B88767A63__INCLUDED_)
#define AFX_VIEWSTRATEGY_H__EC4D2837_CB82_4C72_90B0_0F5B88767A63__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "CheckInterface.h"
class ViewStrategy : public CheckInterface
{
protected:
string title_vew(const char*, const char*) const; //for exact/fuzzy view
void all_vew() const;
string category_vew() const;
Person* anythingView(vector<int>&) const;
public:
virtual ~ViewStrategy(){};
virtual Person* doViewStrategy() = 0;
};
#endif // !defined(AFX_VIEWSTRATEGY_H__EC4D2837_CB82_4C72_90B0_0F5B88767A63__INCLUDED_)

BIN
src/contact/Author.ctt Normal file

Binary file not shown.

BIN
src/contact/Ms.Shrimp.ctt Normal file

Binary file not shown.

237
src/contacts.dsp Normal file
View File

@ -0,0 +1,237 @@
# Microsoft Developer Studio Project File - Name="contacts" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=contacts - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "contacts.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "contacts.mak" CFG="contacts - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "contacts - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "contacts - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "contacts - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD BASE RSC /l 0x804 /d "NDEBUG"
# ADD RSC /l 0x804 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "contacts - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /Yu"stdafx.h" /FD /GZ /c
# ADD BASE RSC /l 0x804 /d "_DEBUG"
# ADD RSC /l 0x804 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "contacts - Win32 Release"
# Name "contacts - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\CheckInterface.cpp
# End Source File
# Begin Source File
SOURCE=.\Contact.cpp
# End Source File
# Begin Source File
SOURCE=.\ContactInterface.cpp
# End Source File
# Begin Source File
SOURCE=.\main.cpp
# End Source File
# Begin Source File
SOURCE=.\MainDelMenu.cpp
# End Source File
# Begin Source File
SOURCE=.\MainMdfMenu.cpp
# End Source File
# Begin Source File
SOURCE=.\MainNewMenu.cpp
# End Source File
# Begin Source File
SOURCE=.\MainStrategy.cpp
# End Source File
# Begin Source File
SOURCE=.\MainVewMenu.cpp
# End Source File
# Begin Source File
SOURCE=.\MainVewMenuInterface.cpp
# End Source File
# Begin Source File
SOURCE=.\Person.cpp
# End Source File
# Begin Source File
SOURCE=.\PrtMenuInterface.cpp
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"stdafx.h"
# End Source File
# Begin Source File
SOURCE=.\ViewAllMenu.cpp
# End Source File
# Begin Source File
SOURCE=.\ViewCategoryMenu.cpp
# End Source File
# Begin Source File
SOURCE=.\ViewExactMenu.cpp
# End Source File
# Begin Source File
SOURCE=.\ViewFuzzyMenu.cpp
# End Source File
# Begin Source File
SOURCE=.\ViewStrategy.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\CheckInterface.h
# End Source File
# Begin Source File
SOURCE=.\Contact.h
# End Source File
# Begin Source File
SOURCE=.\ContactInit.h
# End Source File
# Begin Source File
SOURCE=.\ContactInterface.h
# End Source File
# Begin Source File
SOURCE=.\MainDelMenu.h
# End Source File
# Begin Source File
SOURCE=.\MainMdfMenu.h
# End Source File
# Begin Source File
SOURCE=.\MainNewMenu.h
# End Source File
# Begin Source File
SOURCE=.\MainStrategy.h
# End Source File
# Begin Source File
SOURCE=.\MainVewMenu.h
# End Source File
# Begin Source File
SOURCE=.\MainVewMenuInterface.h
# End Source File
# Begin Source File
SOURCE=.\person.h
# End Source File
# Begin Source File
SOURCE=.\PrtMenuInterface.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# Begin Source File
SOURCE=.\ViewAllMenu.h
# End Source File
# Begin Source File
SOURCE=.\ViewCategoryMenu.h
# End Source File
# Begin Source File
SOURCE=.\ViewExactMenu.h
# End Source File
# Begin Source File
SOURCE=.\ViewFuzzyMenu.h
# End Source File
# Begin Source File
SOURCE=.\ViewStrategy.h
# End Source File
# End Group
# End Target
# End Project

29
src/contacts.dsw Normal file
View File

@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "contacts"=".\contacts.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

BIN
src/contacts.ncb Normal file

Binary file not shown.

BIN
src/contacts.opt Normal file

Binary file not shown.

114
src/contacts.plg Normal file
View File

@ -0,0 +1,114 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: contacts - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\Users\dell\AppData\Local\Temp\RSP5730.tmp" with contents
[
/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR"Debug/" /Fp"Debug/contacts.pch" /Yu"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
"C:\Users\dell\Desktop\Ñ϶÷ΰ 201624450324\Contacts\CheckInterface.cpp"
"C:\Users\dell\Desktop\Ñ϶÷ΰ 201624450324\Contacts\Contact.cpp"
"C:\Users\dell\Desktop\Ñ϶÷ΰ 201624450324\Contacts\ContactInterface.cpp"
"C:\Users\dell\Desktop\Ñ϶÷ΰ 201624450324\Contacts\main.cpp"
"C:\Users\dell\Desktop\Ñ϶÷ΰ 201624450324\Contacts\MainDelMenu.cpp"
"C:\Users\dell\Desktop\Ñ϶÷ΰ 201624450324\Contacts\MainMdfMenu.cpp"
"C:\Users\dell\Desktop\Ñ϶÷ΰ 201624450324\Contacts\MainNewMenu.cpp"
"C:\Users\dell\Desktop\Ñ϶÷ΰ 201624450324\Contacts\MainStrategy.cpp"
"C:\Users\dell\Desktop\Ñ϶÷ΰ 201624450324\Contacts\MainVewMenu.cpp"
"C:\Users\dell\Desktop\Ñ϶÷ΰ 201624450324\Contacts\MainVewMenuInterface.cpp"
"C:\Users\dell\Desktop\Ñ϶÷ΰ 201624450324\Contacts\Person.cpp"
"C:\Users\dell\Desktop\Ñ϶÷ΰ 201624450324\Contacts\PrtMenuInterface.cpp"
"C:\Users\dell\Desktop\Ñ϶÷ΰ 201624450324\Contacts\ViewAllMenu.cpp"
"C:\Users\dell\Desktop\Ñ϶÷ΰ 201624450324\Contacts\ViewCategoryMenu.cpp"
"C:\Users\dell\Desktop\Ñ϶÷ΰ 201624450324\Contacts\ViewExactMenu.cpp"
"C:\Users\dell\Desktop\Ñ϶÷ΰ 201624450324\Contacts\ViewFuzzyMenu.cpp"
"C:\Users\dell\Desktop\Ñ϶÷ΰ 201624450324\Contacts\ViewStrategy.cpp"
]
Creating command line "cl.exe @C:\Users\dell\AppData\Local\Temp\RSP5730.tmp"
Creating temporary file "C:\Users\dell\AppData\Local\Temp\RSP5731.tmp" with contents
[
/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR"Debug/" /Fp"Debug/contacts.pch" /Yc"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
"C:\Users\dell\Desktop\Ñ϶÷ΰ 201624450324\Contacts\StdAfx.cpp"
]
Creating command line "cl.exe @C:\Users\dell\AppData\Local\Temp\RSP5731.tmp"
Creating temporary file "C:\Users\dell\AppData\Local\Temp\RSP5742.tmp" with contents
[
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/contacts.pdb" /debug /machine:I386 /out:"Debug/contacts.exe" /pdbtype:sept
".\Debug\CheckInterface.obj"
".\Debug\Contact.obj"
".\Debug\ContactInterface.obj"
".\Debug\main.obj"
".\Debug\MainDelMenu.obj"
".\Debug\MainMdfMenu.obj"
".\Debug\MainNewMenu.obj"
".\Debug\MainStrategy.obj"
".\Debug\MainVewMenu.obj"
".\Debug\MainVewMenuInterface.obj"
".\Debug\Person.obj"
".\Debug\PrtMenuInterface.obj"
".\Debug\StdAfx.obj"
".\Debug\ViewAllMenu.obj"
".\Debug\ViewCategoryMenu.obj"
".\Debug\ViewExactMenu.obj"
".\Debug\ViewFuzzyMenu.obj"
".\Debug\ViewStrategy.obj"
]
Creating command line "link.exe @C:\Users\dell\AppData\Local\Temp\RSP5742.tmp"
<h3>Output Window</h3>
Compiling...
StdAfx.cpp
Compiling...
CheckInterface.cpp
Contact.cpp
ContactInterface.cpp
main.cpp
MainDelMenu.cpp
MainMdfMenu.cpp
MainNewMenu.cpp
MainStrategy.cpp
MainVewMenu.cpp
MainVewMenuInterface.cpp
Person.cpp
PrtMenuInterface.cpp
ViewAllMenu.cpp
ViewCategoryMenu.cpp
ViewExactMenu.cpp
ViewFuzzyMenu.cpp
ViewStrategy.cpp
Generating Code...
Linking...
Creating temporary file "C:\Users\dell\AppData\Local\Temp\RSP63A7.tmp" with contents
[
/nologo /o"Debug/contacts.bsc"
".\Debug\StdAfx.sbr"
".\Debug\CheckInterface.sbr"
".\Debug\Contact.sbr"
".\Debug\ContactInterface.sbr"
".\Debug\main.sbr"
".\Debug\MainDelMenu.sbr"
".\Debug\MainMdfMenu.sbr"
".\Debug\MainNewMenu.sbr"
".\Debug\MainStrategy.sbr"
".\Debug\MainVewMenu.sbr"
".\Debug\MainVewMenuInterface.sbr"
".\Debug\Person.sbr"
".\Debug\PrtMenuInterface.sbr"
".\Debug\ViewAllMenu.sbr"
".\Debug\ViewCategoryMenu.sbr"
".\Debug\ViewExactMenu.sbr"
".\Debug\ViewFuzzyMenu.sbr"
".\Debug\ViewStrategy.sbr"]
Creating command line "bscmake.exe @C:\Users\dell\AppData\Local\Temp\RSP63A7.tmp"
Creating browse info file...
<h3>Output Window</h3>
<h3>Results</h3>
contacts.exe - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

15
src/io/MainMenu.io Normal file
View File

@ -0,0 +1,15 @@
==========MAIN MENU===========
|
---New___1-------------------
|
---Delete_2------------------
|
---Modify_3------------------
|
---View___4------------------
|
---Quit___5------------------

10
src/io/View.io Normal file
View File

@ -0,0 +1,10 @@
====Options=======
|
-------Delete_1---
|
-------Modify_2---
|
-------Back___3---

22
src/io/ViewMenu.io Normal file
View File

@ -0,0 +1,22 @@
==========VIEW CONTACT========
|
---********------------------
|
---********------------------
|
---********------------------
|
---View___*------------------
| |
-----Exact query__1-------
| |
-----Fuzzy query__2-------
| |
-----Category_____3-------
| |
-----All__________4-------
| |
-----Back_________5-------
|
---********------------------

29
src/main.cpp Normal file
View File

@ -0,0 +1,29 @@
/*
========Program Entry========
Author: ÑÏ÷ΰ
Version: 1.2
Submit Date: 18.06.20
=========================
*/
#include "stdafx.h"
#include "Contact.h"
int main(int argc, char* argv[])
{
Contact* my_contact = new Contact();
ContactInterface* my_interface = my_contact;
ContactInit* my_init = my_contact;
my_init->welcome();
while(1){
my_init->refresh();
if (my_interface->main_menu() == -1)
break;
}
delete my_contact;
return 0;
}