-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
60 lines (55 loc) · 2.27 KB
/
main.cpp
File metadata and controls
60 lines (55 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zelhajou <zelhajou@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/26 17:13:33 by zelhajou #+# #+# */
/* Updated: 2024/06/05 10:25:02 by zelhajou ### ########.fr */
/* */
/* ************************************************************************** */
#include <iostream>
#include <string>
#include "Contact.hpp"
#include "PhoneBook.hpp"
#include <iomanip>
void phoneBookMenu()
{
std::cout << "**********************************************" << std::endl;
std::cout << "* *" << std::endl;
std::cout << "*\033[1m\033[38;5;46m Welcome to the PhoneBook Application \033[0m*" << std::endl;
std::cout << "* *" << std::endl;
std::cout << "**********************************************" << std::endl;
std::cout << "Menu:" << std::endl;
std::cout << "> \033[38;5;226mADD\033[0m : Add a new contact" << std::endl;
std::cout << "> \033[38;5;226mSEARCH\033[0m : Search for a contact" << std::endl;
std::cout << "> \033[38;5;226mEXIT\033[0m : Exit the PhoneBook" << std::endl;
std::cout << "**********************************************" << std::endl;
}
int main()
{
std::string command;
PhoneBook phoneBook;
phoneBookMenu();
while (true)
{
std::cout << "Please enter a command (ADD, SEARCH, EXIT): " << std::endl;
std::getline(std::cin, command);
if (std::cin.eof())
break;
if (command == "ADD")
phoneBook.addContact();
else if (command == "SEARCH")
phoneBook.searchContact();
else if (command == "EXIT")
break;
else if (command.empty())
continue;
else
std::cout << "Invalid command" << std::endl;
if (std::cin.eof())
break;
}
return (0);
}