Commit 1f9f0a12 authored by Oskars's avatar Oskars
Browse files

Change: updating previeously made classes

parent 5db3fc88
......@@ -17,6 +17,14 @@ public class Page {
followers = new ArrayList<User>();
postsInPage = new ArrayList<Post>();
}
public Page (String title, String description, ArrayList<User> followers, ArrayList<Post> postsInPage) {
setTitle(title);
setDescription(description);
setFollowers(followers);
setPostsInPage(postsInPage);
}
//SETTERS
public void setTitle(String title) {
this.title = (title != null) ? title : "no title";
......@@ -27,11 +35,11 @@ public class Page {
}
public void setFollowers(ArrayList<User> followers) {
if(followers != null && !followers.isEmpty() ) this.followers = followers;
followers = (followers != null)? followers : new ArrayList<User>();
}
public void setPostsInPage(ArrayList<Post> posts) {
if(posts != null && !posts.isEmpty() ) postsInPage = posts;
posts = (posts != null)? postsInPage : new ArrayList<Post>();
}
//GETTERS
......
package model.users;
import java.util.ArrayList;
import model.Page;
import model.Post;
public class BusinessUser extends User{
ArrayList<Page> listOfPages;
//CONSTRUCTORS
public BusinessUser () {
super();
listOfPages = new ArrayList<Page>();
}
public BusinessUser (String nameAndSurname, String username, String password, ArrayList<Page> listOfPages) {
super(nameAndSurname, username, password);
this.listOfPages = (listOfPages != null)? listOfPages : new ArrayList<Page>();
}
//SETTERS
public ArrayList<Page> getListOfPages() {
return listOfPages;
}
//GETTERS
public void setListOfPages(ArrayList<Page> listOfPages) {
this.listOfPages = (listOfPages != null)? listOfPages : new ArrayList<Page>();
}
//OTHER METHODS
public String toString() {
return super.toString() + ", Pages: " + listOfPages.size();
}
public void createPage() {
}
}
......@@ -19,25 +19,26 @@ public class PrivateUser extends User {
public PrivateUser(String nameAndSurname, String username, String password, ArrayList<Post> posts, ArrayList<User> followers) {
super(nameAndSurname, username, password);
this.posts = (posts != null)? posts : new ArrayList<Post>();
this.followers = (followers != null)? followers : new ArrayList<User>();
setPosts(posts);
setFollowers(followers);
}
//SETTERS
public void setUser(User user) {
if(user != null) {
this.setNameAndSurname(user.getNameAndSurname());
this.setUsername(user.getUsername());
this.setPassword(user.getPassword());
}
}
// public void setUser(User user) {
// if(user != null) {
// this.setNameAndSurname(user.getNameAndSurname());
// this.setUsername(user.getUsername());
// this.setPassword(user.getPassword());
// }
// }
public void setPosts(ArrayList<Post> posts) {
if(posts != null) this.posts = posts;
this.posts = (posts != null)? posts : new ArrayList<Post>();
}
public void setFollowers(ArrayList<User> followers) {
if(followers != null) this.followers = followers;
this.followers = (followers != null)? followers : new ArrayList<User>();
}
//GETTERS
......
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