103 lines
2.8 KiB
C++
103 lines
2.8 KiB
C++
#include <iostream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
using namespace std;
|
|
|
|
#include "menu.h"
|
|
#include "person.h"
|
|
#include "people.h"
|
|
|
|
int main() {
|
|
people peeps;
|
|
peeps.add_person("Kevin Bacon", "bacon");
|
|
|
|
menu m;
|
|
string option;
|
|
bool done = false;
|
|
while(not done) {
|
|
cout << endl << m;
|
|
getline(cin, option);
|
|
if(option[0] == '#')
|
|
continue;
|
|
if (option[0] == 'a') {
|
|
cout << "adding a person" << endl;
|
|
string name, food;
|
|
cout << "name: ";
|
|
getline(cin, name);
|
|
cout << "food: ";
|
|
getline(cin, food);
|
|
peeps.add_person(name, food);
|
|
}
|
|
else if (option[0] == 'd') {
|
|
cout << "displaying people" << endl;
|
|
cout << peeps << endl;
|
|
}
|
|
else if (option[0] == 'm') {
|
|
cout << "make connection" << endl;
|
|
cout << peeps << endl;
|
|
try {
|
|
unsigned int a, b;
|
|
get_two_indices(peeps, a, b);
|
|
peeps.connect(a, b);
|
|
}
|
|
catch(string e) {
|
|
cerr << e << endl;
|
|
}
|
|
}
|
|
else if (option[0] == 'b') {
|
|
cout << "break connection" << endl;
|
|
cout << peeps << endl;
|
|
try {
|
|
unsigned int a, b;
|
|
get_two_indices(peeps, a, b);
|
|
peeps.unfriend(a, b);
|
|
}
|
|
catch(string e) {
|
|
cerr << e << endl;
|
|
}
|
|
}
|
|
else if (option[0] == 'c') {
|
|
cout << "change food" << endl;
|
|
cout << peeps << endl;
|
|
try {
|
|
unsigned int a;
|
|
get_index(peeps, a, "enter index of person who needs changing: ");
|
|
cout << "new food: ";
|
|
cin.ignore();
|
|
getline(cin, option);
|
|
peeps.food_update(a, option);
|
|
}
|
|
catch(string e) {
|
|
cerr << e << endl;
|
|
}
|
|
}
|
|
else if (option[0] == 's') {
|
|
cout << "show food friends" << endl;
|
|
try {
|
|
unsigned int a;
|
|
get_index(peeps, a, "enter index of person for food friend: ");
|
|
peeps[a]->food_friend();
|
|
}
|
|
catch(string e) {
|
|
cerr << e << endl;
|
|
}
|
|
}
|
|
else if (option[0] == 'e') {
|
|
try {
|
|
unsigned int a;
|
|
get_index(peeps, a, "enter index of person for who I shall calculate the Bacon Number: ");
|
|
cout << peeps[a]->bacon_number() << endl;
|
|
}
|
|
catch(string e) {
|
|
cerr << e << endl;
|
|
}
|
|
}
|
|
else if (option[0] == 'q') {
|
|
cout << "quitting" << endl;
|
|
done = true;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|