Commit 2cd6946a authored by Oskars's avatar Oskars
Browse files

Change: minor changes

parent f25533e1
......@@ -4,5 +4,5 @@ import model.PostType;
public interface IPost {
public void createPost(PostType postType);
public void createPost(PostType postType, String msg);
}
......@@ -18,7 +18,14 @@ public class Post {
postType= PostType.PRIVATE;
}
public Post(String msg, PostType postType) {
// public Post(PostType postType) {
// msg = "Empty";
// date = LocalDate.now();
// countOfLikes = 0;
// setPostType(postType);
// }
public Post(PostType postType, String msg) {
this.msg = (msg != null) ? msg : "";
this.postType = (postType != null)? postType : PostType.PRIVATE;
date = LocalDate.now();
......
......@@ -3,8 +3,10 @@ package model.users;
import java.util.ArrayList;
import model.Page;
import model.Post;
import model.PostType;
import ifaces.IPost;
public class BusinessUser extends User{
public class BusinessUser extends User implements IPost{
ArrayList<Page> listOfPages;
......@@ -44,4 +46,19 @@ public class BusinessUser extends User{
listOfPages.add(page);
}
//IPLEMENTED METHODS
public void createPost(PostType postType, String message, Page page){
super.createPost(postType);
Post newPost = new Post(postType, message);
for(Page pag: listOfPages) {
if(pag.getTitle() == page.getTitle()) {
ArrayList<Post> postsInPage = pag.getPostsInPage();
postsInPage.add(newPost);
pag.setPostsInPage(postsInPage);
}
}
}
}
......@@ -2,11 +2,11 @@ package model.users;
import java.util.ArrayList;
import model.Post;
//import model.PostType;
import model.PostType;
public class PrivateUser extends User {
public class PrivateUser extends User{
//private ArrayList<Post> privatePosts;
//private ArrayList<Post> publicPosts;
private ArrayList<Post> posts;
private ArrayList<User> followers;
......@@ -62,7 +62,13 @@ public class PrivateUser extends User {
privateUser.setFollowers(uf);
}
}
//DERRIVED ABSTRACT METHODS
//@Override
//public void createPost(PostType postType, String message){
// Post newPost = new Post(postType, message);
// posts.add(newPost);
//}
}
package model.users;
import java.util.ArrayList;
import model.Encryption;
import model.Page;
//import model.PostType;
import model.Verification;
//import model.users.GuestUser;
import ifaces.IPost;
//import model.Post;
public class User extends GuestUser{
public abstract class User extends GuestUser implements IPost{
private String nameAndSurname;
private String username;
......@@ -91,7 +92,6 @@ public class User extends GuestUser{
}
public boolean followPage(Page page) {
if(page!= null) {
ArrayList<User> pageFollowers = page.getFollowers();
pageFollowers.add(this);
......@@ -99,7 +99,11 @@ public class User extends GuestUser{
return true;
}
return false;
}
//IMPLEMENTED METHODS
//public void createPost(PostType postType, String msg) {}
//don't implement this if derived classes has to have implementation
//}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment