-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
68 lines (62 loc) · 1.72 KB
/
main.cpp
File metadata and controls
68 lines (62 loc) · 1.72 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
61
62
63
64
65
66
67
68
#include<iostream>
#include<iomanip>
using namespace std;
#include"Person.hpp"
#include<vector>
Person newPerson()
{
system("clear");
Person temp;
string temp_name;
cout<<"Choose name: ";
cin>>temp_name;
temp.setName(temp_name);
return temp;
}
int removePerson(vector<Person>&persons)
{
system("clear");
int ret;
do{
for(int i=0; i < persons.size(); i++) {
cout<<setw(3)<<left<<i+1<<setw(20)<<right<<persons[i].getName()<<endl;
}
cin>>ret;
}while(!cin.good());
return ret;
}
int main()
{
vector<Person>persons;
bool run=true;
while(run)
{
int cmd;
system("clear");
cout<<"Personality Generator"<<endl;
cout<<setw(3)<<setfill('-')<<left<<"1"<<setw(20)<<right<<"Add Person"<<endl;
cout<<setw(3)<<left<<"2"<<setw(20)<<right<<"Remove Person"<<right<<endl;
cout<<setw(3)<<left<<"3"<<setw(20)<<right<<"Edit Person"<<endl;
cout<<endl<<setw(3)<<left<<"9"<<setw(20)<<right<<"Start Playing"<<endl;
cout<<setw(3)<<left<<"0"<<setw(20)<<right<<"Exit"<<endl;
cin>>cmd;
if(cmd == 1) {
persons.push_back(newPerson());
} else if(cmd == 2) {
persons.erase(persons.begin()+removePerson(persons));
} else if(cmd == 3) {
system("clear");
if(persons.size() < 1) {
cout<<"No person to edit."<<endl;
sleep(1);
}
for(int i=0; i < persons.size(); i++) {
cout<<setw(3)<<left<<i+1<<setw(20)<<right<<persons[i].getName()<<endl;
}
cin>>cmd;
} else if(cmd == 0) {
run = false;
}
}
system("clear");
}