-
Notifications
You must be signed in to change notification settings - Fork 0
/
Post.java
74 lines (60 loc) · 1.71 KB
/
Post.java
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
package queuecode;
import java.util.Scanner;
import java.util.ArrayList;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
class Comment{
String createdAt;
String content;
void newcomment(String content){
LocalDateTime myDateObj = LocalDateTime.now();
DateTimeFormatter myFormatObj =
DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");
this.createdAt = myDateObj.format(myFormatObj);
this.content = content;
}
}
public class Post {
String createdBy;
String createdAt;
String lyrics;
String artist;
String genre;
String lang;
int viewsCount;
int likesCount;
// reference follower newly from user graph
private ArrayList<Comment> userComments = new ArrayList<Comment>();
private ArrayList<String> likes = new ArrayList<String>();
private ArrayList<String> seen = new ArrayList<String>();
void createPost(String username, String lyrics){
createdBy = username;
this.lyrics = lyrics;
LocalDateTime myDateObj = LocalDateTime.now();
DateTimeFormatter myFormatObj =
DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");
this.createdAt = myDateObj.format(myFormatObj);
}
void seen(String username) {
if(!seen.contains(username)) {
//Insert the artist,genre,lang
seen.add(username);
viewsCount++;
}
}
void liked(String username) {
if(likes.contains(username)) {
//Insert the artist,genre,lang
// likes.remove(likes.indexOf(username));
likes.add(username);
likesCount++;
}
}
void comment(String username) {
Comment c=new Comment();
Scanner sc=new Scanner(System.in);
String content = sc.nextLine();
c.newcomment(content);
userComments.add(c);
}
}