#include <iostream>
#include "pep.h"
#include "pep.cpp"
#include"pch.h"
using namespace std;
void maniu();
void maniu1();
void maniu2();
void maniu3();
void maniu() {
cout << "通讯录管理系统 " << endl;
cout << "1. 添加联系人" << endl;
cout << "2. 删除联系人" << endl;
cout << "3. 查看当前通讯录" << endl;
cout << "4.清空通讯录" << endl;
cout << "退出 :-1 " << endl;
cout << endl;
};
void maniu1() {
cout << " 请选择从开头添加或从末尾添加" << endl;
cout << " 开头: 1 末尾: 2" << endl;
cout << "返回上一级: 3 " << endl;
cout << endl;
};
void maniu2() {
cout << "请选择删除的位置" << endl;
cout << "按编号删除:1 删除开头:2 删除末尾: 3" << endl;
cout << "返回上一级: 4 " << endl;
cout << endl;
};
void maniu3() {
cout << "是否要按编号修改联系人" << endl;
cout << " 是:1 否:0" << endl;
cout << endl;
};
int main()
{
LinkList<int> A;
maniu();
int X = 0;
cout << "请输入数字" << endl;
while (X != -1)
{
cin >> X; cout << endl;
if (X == 1) {
A.show();
maniu1();
int i1 = 0;
while (0 <= i1 && i1 <= 3)
{
cin >> i1;
if (i1 == 1) {
cout << "请输入姓名 电话号码" << endl;
char* a = new char[7], * b = new char[12];
cin >> a >> b;
A.add(a, b);
A.show();
maniu1();
int i1 = 0;
cout << endl;
}
else if (i1 == 2) {
cout << "请输入姓名 电话号码" << endl;
char* a = new char[7], * b = new char[12];
cin >> a >> b;
int nn;
nn = A.numx();
if (nn == 0) { A.add(a, b); }
else { A.addend(a, b); };
A.show();
maniu1();
int i1 = 0;
cout << endl;
}
else if (i1 == 3) {
cout << endl;
maniu();
X = 0;
cout << endl;
break;
}
else
{
cout << "没有此项操作" << endl;
cout << "请重新输入数字选择你想要的操作" << endl;
A.show();
maniu1();
int i1 = 5;
cout << endl;
};
}
}
else if (X == 2) {
cout << "当前联系人数量:" << " " ;
int nn;
nn = A.numx();
cout<< nn << endl;
A.show();
maniu2();
int i2 = 1;
while (i2 <= 4 && i2 >= 1){
cin >> i2;
if (i2 == 1) {
int x;
cin >> x;
A.delete1(x);
A.show();
maniu2();
i2 = 1;
cout << endl;
}
else if (i2 == 2) {
A.delete3();
A.show();
maniu2();
i2 = 1;
cout << endl;
}
else if (i2 == 3) {
A.delete4();
A.show();
maniu2();
i2 = 1;
cout << endl;
}
else if (i2 == 4) {
cout << endl;
maniu();
X = 0;
break;
}
else {
cout << "没有此项操作" << endl;
cout << "请重新输入数字选择你想要的操作" << endl;
A.show();
maniu2();
i2 = 1;
cout << endl;
}
}
}
else if (X == 3) {
A.show();
if (A.numx() != 0) {
maniu3();
int i3 = 0;
while (i3 == 0)
{
cin >> i3;
if (i3 == 1) {
int i31;
cout << "请输入编号" << endl;
cin >> i31;
break;
}
else if (i3 == 0) {
cout << endl;
maniu();
X = 0;
cout << endl;
break;
}
}
}
else {
cout << " 列表为空" << endl;
cout << endl;
maniu();
X = 0;
cout << endl;
}
}
else if (X == 4)
{
A.delete2();
cout << endl;
maniu();
X = 0;
};
}
return 0;
}