Update README.md

pue2kga9m 1 year ago
parent 18e17ca423
commit b4117f04f4

@ -1,2 +1,52 @@
# Lin_Address_Book_Management_System
#include "ContactManager.h"
#include <iostream>
void ContactManager::addContact() {
Contact newContact;
std::cout << "请输入联系人姓名: ";
std::cin >> newContact.name;
std::cout << "请输入联系人电话: ";
std::cin >> newContact.phone;
newContact.id = contacts.size() + 1;
contacts.push_back(newContact);
}
void ContactManager::displayContacts() const {
std::cout << "通讯录如下:" << std::endl;
for (const auto& contact : contacts) {
std::cout << "ID" << contact.id << ", " << contact.name << ", " << contact.phone << std::endl;
}
}
void ContactManager::findContact() const {
int id;
std::cout << "请输入要查找的联系人ID ";
std::cin >> id;
for (const auto& contact : contacts) {
if (contact.id == id) {
std::cout << "找到联系人ID " << contact.id << ", " << contact.name << ", " << contact.phone << std::endl;
return;
}
}
std::cout << "未找到联系人。" << std::endl;
}
void ContactManager::deleteContact() {
int id;
std::cout << "请输入要删除的联系人ID ";
std::cin >> id;
for (auto it = contacts.begin(); it != contacts.end(); ++it) {
if (it->id == id) {
contacts.erase(it);
std::cout << "已删除联系人。" << std::endl;
return;
}
}
std::cout << "未找到联系人。" << std::endl;
}

Loading…
Cancel
Save