forked from raghaddmahgoub/OOP-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserDashBoard.java
More file actions
161 lines (152 loc) · 5.28 KB
/
UserDashBoard.java
File metadata and controls
161 lines (152 loc) · 5.28 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
import org.omg.CORBA.DynAnyPackage.Invalid;
import java.util.Scanner;
public class UserDashBoard {
static Scanner in = new Scanner(System.in);
static User user;
Feed feed;
public UserDashBoard(User user) {
this.user = user;
viewDashboard();
}
public void viewDashboard() {
System.out.println("1-View Your Profile");
System.out.println("2-Update Your Profile");
System.out.println("3-view my post");
System.out.println("4-Back To Your Feed");
boolean InvalidChoice = true;
while (InvalidChoice = true) {
int choice = in.nextInt();
switch (choice) {
case 1:
viewProfile();
break;
case 2:
updateProfile();
break;
case 3:
Feed.view_my_posts(user);
break;
case 4:
backToFeed();
break;
default:
System.out.println("Invalid choice, try again: ");
break;
}
}
}
public void viewProfile() {
System.out.println("Profile:");
System.out.println("UserName " + user.getUserName());
System.out.println("Email: " + user.getEmail());
System.out.println("Gender: " + user.getGender());
System.out.println("Date of birth: " + user.getBirthdateString());
// System.out.println("Date Of Birth: " + user.getBirthdate());
System.out.println("Phone Number: " + user.getPhoneNumber());
System.out.println("1- Return back to dashboard");
System.out.println("2- Return back to feed");
boolean InvalidChoice = true;
while (InvalidChoice = true) {
int choice = in.nextInt();
switch (choice) {
case 1:
viewDashboard();
break;
case 2:
backToFeed();
break;
default:
System.out.println("Invalid Choice");
InvalidChoice = true;
}
}
}
public void updateProfile() {
System.out.println("1- Update Your UserName");
System.out.println("2- Change Your Password");
System.out.println("3- Return To Dashboard");
boolean InvalidChoice = true;
while (InvalidChoice = true) {
int choice = in.nextInt();
switch (choice) {
case 1:
updateUserName();
break;
case 2:
changePassword();
break;
case 3:
viewDashboard();
break;
default:
System.out.println("Invalid Choice, try again: ");
break;
}
}
}
public void updateUserName() {
boolean InvalidChoice = true;
System.out.println("Current User Name: " + user.getUserName());
System.out.println("Enter your New Name: ");
user.setUser_Name(in.next());
while (user.getUserName().length() < 8) {
System.out.println("Username Should be More Than 8 Characters, Try Again: ");
System.out.println("Enter Username :");
user.setUser_Name(in.next());
}
System.out.println("Username is updated successfully :)");
System.out.println("Your new username is " + user.getUserName());
System.out.println("1- Return back to dashboard");
System.out.println("2- Return back to feed");
System.out.println("3- View your profile");
while (InvalidChoice = true) {
int choice = in.nextInt();
switch (choice) {
case 1:
viewDashboard();
break;
case 2:
backToFeed();
break;
case 3:
viewProfile();
break;
default:
System.out.println("Invalid Choice, Try Again: ");
}
}
}
public void changePassword() {
String oldPassword;
String NewPassword;
System.out.println("Enter your current password: ");
oldPassword = in.next();
while (!user.getPassword().equals(oldPassword)) {
System.out.println("Wrong Password, Please try again: ");
oldPassword = in.next();
}
System.out.println("Enter your New password: ");
NewPassword = in.next();
while (NewPassword.length() < 8){
System.out.println("Password Should be More Than 8 Characters, Try Again: ");
NewPassword = in.next();
}
user.setPassword(NewPassword);
System.out.println("password updated successfully");
viewDashboard();
}
void ViewPostsOfMe() {
System.out.println ("Posts");
for (Post Posts : user.getAllPosts())
{
System.out.println(Posts);
}
}
public void editPost(Post post){
String edittedContent= in.next();
post.setContent(edittedContent);
}
public void backToFeed() {
feed = new Feed(user);
}
}