-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.java
More file actions
178 lines (142 loc) · 4.36 KB
/
Copy pathUser.java
File metadata and controls
178 lines (142 loc) · 4.36 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package socialmedia;
import java.util.*;
/**
*
* @author alizeidillazyuksel
*/
public class User {
private String name;
private String surname;
private Date birthday;
private String email;
private String address;
private User [] followers;
private User [] followed;
private Message [] inbox;
private Message []outbox;
private int inboxCount;
private int outboxCount;
private int followersCount;
private int followedCount;
public User(String name,String surname,Date birthday,String email,String address){
this.name = name;
this.surname = surname;
this.birthday = birthday;
this.email = email;
this.address = address;
this.followers = new User[10000];
this.followed = new User[10000];
this.inbox = new Message[10];
this.outbox = new Message[10];
}
public void AddFollower(User u){
if(this.followersCount > this.followers.length -1){
User temp [] = this.followers;
this.followers = new User[temp.length*2];
for(int i = 0; i<temp.length; i++){
this.followers[i] = temp[i];
}
}
this.followers[followersCount] = u;
this.followersCount++;
}
public void follow(User u){
if(this.followedCount > this.followed.length-1){
User temp [] = this.followed;
this.followed = new User[temp.length*2];
for(int i = 0; i<temp.length; i++){
this.followed[i] = temp[i];
}
}
this.followed[followedCount] = u;
this.followedCount++;
u.AddFollower(this);
}
public User[] getFollowers() {
return followers;
}
public void setFollowers(User[] followers) {
this.followers = followers;
}
public User[] getFollowed() {
return followed;
}
public void setFollowed(User[] followed) {
this.followed = followed;
}
public int getFollowersCount() {
return followersCount;
}
public void setFollowersCount(int followersCount) {
this.followersCount = followersCount;
}
public int getFollowedCount() {
return followedCount;
}
public void setFollowedCount(int followedCount) {
this.followedCount = followedCount;
}
public void setName(String name){
this.name = name;
}
public void setSurname(String surname){
this.surname = surname;
}
public void setBirthday(Date birthday){
this.birthday = birthday;
}
public void setEmail(String email){
this.email = email;
}
public void setAddress(String address){
this.address = address;
}
public String getName(){
return this.name;
}
public String getSurname(){
return this.surname;
}
public Date getBirthday(){
return this.birthday;
}
public String getEmail(){
return this.email;
}
public String getAddress(){
return this.address;
}
public void sendMessage(String content , User receiver){
Message m = new Message(content,this,receiver);
if(outboxCount > this.outbox.length-1){
Message [] temp = this.outbox;
this.outbox =new Message[temp.length*2];
for(int i = 0; i<temp.length; i++){
this.outbox[i] =temp[i];
}
}
this.outbox[outboxCount] = m;
this.outboxCount++;
}
public void receiveMessage(Message m){
if(inboxCount > this.inbox.length-1){
Message [] temp = this.inbox;
this.inbox =new Message[temp.length*2];
for(int i = 0; i<temp.length; i++){
this.inbox[i] =temp[i];
}
}
this.inbox[inboxCount] = m;
this.inboxCount++;
}
public void showMessagefromInbox(int index){
this.inbox[index].writeMessagetoConsole();
}
public void showMessagefromOutbox(int index){
// this.inbox[index].
}
}