-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfile.java
More file actions
96 lines (82 loc) · 2.72 KB
/
Profile.java
File metadata and controls
96 lines (82 loc) · 2.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
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
import java.util.ArrayList;
/* Profile.java
* a Profile class that holds information of a user's profile which includes
* the user's username, full name, email, phone number, and list of friends
*
* @author Alexis Luo
*/
public class Profile {
private String userName;
private ArrayList<Profile> friends;
private String firstName;
private String lastName;
//constructors
public Profile(){
userName = "";
friends = new ArrayList<Profile>();
firstName = "";
lastName = "";
}
public Profile(String userName, String first, String last) {
this.userName = userName;
this.friends = new ArrayList<Profile>();
this.firstName = first;
this.lastName = last;
}
//getters and setters
public String getName() {
return userName;
}
public void setName(String userName) {
this.userName = userName;
}
public ArrayList<Profile> getFriendList(){
return friends;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public boolean addFriend(Profile friendToAdd) {
if(friends.contains(friendToAdd)) {
//System.out.println(friendToAdd.getFirstName() + " " + friendToAdd.getLastName() + " is already a friend.");
return false;
}
else {
friends.add(friendToAdd);
return true;
}
}
public boolean removeFriend(Profile friendToRemove) {
if(friends.contains(friendToRemove)) {
friends.remove(friendToRemove);
return true;
}
else {
//System.out.println(friendToRemove.getFirstName() + " " + friendToRemove.getLastName() + " is not on the friend's list");
return false;
}
}
public void displayProfile(){ //displays full name, username, and friends list of user
System.out.println(" . ----------");
System.out.println(" | USERNAME: " );
System.out.println(" | " + getName());
System.out.println(" | NAME: " );
System.out.println(" | " + getFirstName() + " " + getLastName());
System.out.println(" | LIST OF FRIENDS (PEOPLE FOLLOWING): " );
for (int i=0; i<friends.size(); i++){
Profile aFriend = friends.get(i);
System.out.println(" | " + aFriend.getName() + " - " + aFriend.getFirstName() + " " + aFriend.getLastName());
}
System.out.println(" . ----------");
System.out.println();
}
}