Untitled
unknown
plain_text
a year ago
6.4 kB
3
Indexable
Never
\\Post Class /* * 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 com.oopassignment3; import java.util.ArrayList; public class Post { private String text; private User author; private ArrayList<User> likes=new ArrayList<>(); private ArrayList<Comment> comments=new ArrayList<>(); public Post(){} public Post(String text,User author){ this.text=text; this.author=author; } public String getText(){return text;} public User getUser(){return author;} public ArrayList<User> getLikes(){return likes;} public ArrayList<Comment> getComments(){return comments;} public void setText(String text){this.text=text;} public void setAuthor(User author){this.author=author;} public void setLikes(User user){this.likes.add(user);} public void setLikes(Comment comments){this.comments.add(comments);} @Override public String toString(){ return "------------------------------------\n"+"Post: "+this.getText()+"\nLikes: "+(this.getLikes().size())+"\nComments: "+this.getComments()+"\n\nUser: "+(this.getUser().getUsername())+"\nPosts: "+(this.getUser().getPostList().size())+"\nFollowers: "+(this.getUser().getFollowerList().size())+"\nFollowing: "+(this.getUser().getFollowingList().size())+"\n-----------------------------------"; } } \\User class /* * 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 com.oopassignment3; /** * * @author hp */ import java.util.ArrayList; public class User { private String username; private ArrayList<User> followerList=new ArrayList<>(); private ArrayList<User> followingList=new ArrayList<>(); private ArrayList<Post> postList=new ArrayList<>(); private ArrayList<Comment> commentsList=new ArrayList<>(); public User(){} public User(String username){ this.username=username; } public String getUsername(){return username;} public ArrayList<User> getFollowerList(){return followerList;} public ArrayList<User> getFollowingList(){return followingList;} public ArrayList<Post> getPostList(){return postList;} public ArrayList<Comment> getCommentList(){return commentsList;} public String totring(){ return "*********USER Info********\n"+"username: "+this.getUsername()+"\nPosts: "+this.getPostList().size()+"\nFollowers: "+this.getFollowerList().size()+"\nFollowing: "+this.getFollowingList().size()+"\n-----------------------\n"; } } \\comment class /* * 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 com.oopassignment3; /** * * @author hp */ public class Comment { private String text; private User author; private Post post; public Comment(String text,User author,Post post){ this.text=text; this.author=author; this.post=post; } public Comment(){} public String getText(){return text;} public User getUser(){return author;} public Post getpost(){return post;} public void setText(String text){ this.text=text;} public void setUser(User author){ this.author=author;} public void setPost(Post post){ this.post=post;} @Override public String toString(){ String output= "---------------------------------------\n"+"Comment: "+(this.getText())+"\n\nUser: "+(this.getUser().getUsername())+"\nPosts: "+(this.getUser().getPostList().size())+"\nFollowers: "+(this.getUser().getFollowerList().size())+"\nFollowing: "+(this.getUser().getFollowingList().size())+"\n-----------------------------------"; return output; } } \\Tag class /* * 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 com.oopassignment3; import java.util.ArrayList; public class Tag { private User taggedUser; private User taggingUser; private Post post; public Tag(){}; public Tag(User taggingUser,User taggedUser){ this.taggingUser=taggingUser; this.taggedUser=taggedUser; } public void setTaggedUser(User taggedUser ){ this.taggedUser=taggedUser; } public void setTaggingUser(User taggingUser ){ this.taggingUser=taggingUser; } public User getTaggedUser(){ return taggedUser; } public User getTaggingUser(){ return taggingUser; } /** * * @return */ @Override public String toString(){ return "----------------------------------\nTags\n"+this.getTaggingUser().getUsername()+" Tagged "+this.getTaggedUser().getUsername()+"\n------------------------------------------------------\n"; } } \\follow class /* * 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 com.oopassignment3; /** * * @author hp */ public class Follow { private User following; private User follower; public Follow(){} public Follow(User following,User follower){ this.following=following; this.follower=follower; } public void setfollowing(User following){this.following=following;} public void setfollower(User follower){this.follower=follower;} public User getFollowing(){return following;} public User getfollower(){return follower;} /** * * @return */ @Override public String toString(){ return "------------------------\nFollow Updates\n"+this.getFollowing().getUsername()+" started following "+this.getfollower().getUsername()+"\n-----------------------------------\n"; } }