-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.cpp
More file actions
117 lines (78 loc) · 1.47 KB
/
user.cpp
File metadata and controls
117 lines (78 loc) · 1.47 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <iostream>
#include <vector>
#include "user.h"
#include <fstream>
#include <string>
using namespace std;
User::User(string user, int birthday, int zipcode, int ID){
name=user;
year=birthday;
zip=zipcode;
userId=ID;
}
User::User(){
year=0;
zip=0;
userId=0;
}
User::~User(){
}
void User::add_friend(int friendId){
//checking if users are already friends
bool found=false;
for(int i=0; i<id.size(); i++){
if(id[i]==friendId){
found=true;
break;
}
}
if(!found){
id.push_back(friendId);//if not friends add to vector
}
}
void User:: ifFriends(int friendId){ //check if friends
for(int i=0; i<id.size(); i++){
if(id[i]==friendId){
cout << "Already Friends" << endl;
}
}
}
void User::ifNotFriends(int friendId){ //check if not friends
bool found=false;
for(int i=0; i<id.size(); i++){
if(id[i]==friendId){
found=true;
}
}
if(found!=false){
cout << "Not currently friends" << endl;
}
}
void User::delete_friend(int friendId){
//checking if already friends
bool found=false;
for(int i=0; i<id.size(); i++){
if(id[i]==friendId){
found=true;
break;
}
}
if(found==true){ //if friends delete from vector
id.erase(id.begin())+friendId;
}
}
vector<int> User::getfriends(){ //returns user info
return id;
}
string User::getname() const{
return name;
}
int User::getyear() const{
return year;
}
int User::getzip() const{
return zip;
}
int User::getuserId() const{
return userId;
}