-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFriendRequest.java
More file actions
50 lines (45 loc) · 1.48 KB
/
FriendRequest.java
File metadata and controls
50 lines (45 loc) · 1.48 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
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.InputMismatchException;
import java.util.Scanner;
public class FriendRequest extends Notification {
User sender ;
User reciever;
FriendShip relation;
public FriendRequest(User sender, User reciever, FriendShip relation) {
this.sender = sender;
this.reciever = reciever;
this.relation = relation;
TimeStamp= Timestamp.valueOf(LocalDateTime.now());
}
public void expand_friendrequest() {
getTimeStamp();
System.out.println(sender.getUserName() + " sent you a friend request");
System.out.println("1.Accept");
System.out.println("2.Reject");
Scanner in = new Scanner(System.in);
int choice = 0;
Boolean validate=new Boolean(false);
while(!validate) {
try {
choice=in.nextInt();
validate=true;
} catch (InputMismatchException e) {
System.out.println("invaild choice try again");
System.out.print("Enter a choice :");
in.nextLine();
}
}
switch (choice) {
case 1:
relation.acceptFriendRequest(sender);
break;
case 2:
relation.declineFriendRequest(sender);
break;
default:
System.out.println("invalid choice");
expand_friendrequest();
}
}
}