Commit e9e67428 authored by Oskars's avatar Oskars
Browse files

Add: create main class, 2 private users, 2 business users, with posts and pages

parent 6bd61858
......@@ -11,35 +11,61 @@ public class main {
public static void main(String[] args) {
//PRIVATE USER
PrivateUser privateUser1 = new PrivateUser("Oskars Birgelis", "Oskars", "Birgelis", null, null);
PrivateUser privateUser2 = new PrivateUser("Peteris Petersons", "Peteris", "Petersons", null, null);
privateUser1.createPost(PostType.PUBLIC, "this is public PrivateUser Post number 1");
privateUser1.createPost(PostType.PUBLIC, "this is public PrivateUser Post number 2");
privateUser2.createPost(PostType.PRIVATE, "this is private PrivateUser Post number 1");
privateUser2.createPost(PostType.PRIVATE, "this is private PrivateUser Post number 2");
//printPrivateUserInfo(privateUser1);
//printPrivateUserInfo(privateUser2);
//BUSINESS USER
BusinessUser businessUser1 = new BusinessUser("Armands Armandsons", "Armands", "Armandsons", null);
BusinessUser businessUser2 = new BusinessUser("Pavels Pavelsons", "Pavels", "Pavelsons", null);
Post publicPost1 = new Post(PostType.PUBLIC, "this is public Post number 1");
Post publicPost2 = new Post(PostType.PUBLIC, "this is public Post number 2");
Post privatePost1 = new Post(PostType.PRIVATE, "this is private Post number 1");
Post privatePost2 = new Post(PostType.PRIVATE, "this is private Post number 2");
privateUser1.addPost(publicPost1);
privateUser1.addPost(privatePost1);
privateUser2.addPost(publicPost2);
privateUser2.addPost(privatePost2);
Page page1 = new Page("Physics","This is page about physics", null, null);
Page page2 = new Page("Mathematics","This is page about mathematics", null, null);
businessUser1.createPage("Physics","This page is about physics", null, null);
businessUser2.createPage("Mathematics","This page is about mathematics", null, null);
page1.addPostInPage(publicPost1);
page1.addPostInPage(publicPost2);
businessUser1.createPostInPage(PostType.PUBLIC, "this is public BusinessUser Post number 1", businessUser1.findPage("Physics") );
businessUser1.createPostInPage(PostType.PUBLIC, "this is public BusinessUser Post number 2", businessUser1.findPage("Physics") );
page2.addPostInPage(privatePost1);
page2.addPostInPage(privatePost2);
businessUser2.createPostInPage(PostType.PRIVATE, "this is private BusinessUser Post number 1", businessUser1.findPage("Mathematics") );
businessUser2.createPostInPage(PostType.PRIVATE, "this is private BusinessUser Post number 2", businessUser1.findPage("Mathematics") );
//printUserInfo(privateUser1);
printBusinessUserInfo(businessUser1);
printBusinessUserInfo(businessUser2);
}
// public static void printUserInfo(User user) {
// System.out.println(user.toString());
// }
public static void printPrivateUserInfo(PrivateUser user) {
System.out.println(user.toString());
for(Post post : user.getPosts()) {
System.out.println(post.toString());
}
}
public static void printBusinessUserInfo(BusinessUser user) {
System.out.println(user.toString());
//System.out.println(" Pages:");
for(Page page : user.getListOfPages()) {
System.out.print(" ");
System.out.println(page.toString());
//System.out.println(" Posts:");
for(Post post: page.getPostsInPage()) {
System.out.print(" ");
System.out.println(post.toString());
}
}
}
}
......@@ -54,10 +54,6 @@ public class PrivateUser extends User{
}
}
public void addPost(Post post) {
if(post != null) posts.add(post);
}
//DERRIVED ABSTRACT METHODS, includes IPost interface
@Override
public Post createPost(PostType postType, String message){
......
......@@ -96,7 +96,7 @@ public abstract class User extends GuestUser implements IPost{
//OTHER METHODS
public String toString() {
return "User ID: " + super.getId() + "Full name: " + nameAndSurname + ", Username: " + username;
return "User ID: " + super.getId() + ", Full name: " + nameAndSurname + ", Username: " + username;
}
public boolean login(String inputPassword) {
......
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