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

Change: updating previeously made classes

parent 5db3fc88
...@@ -17,6 +17,14 @@ public class Page { ...@@ -17,6 +17,14 @@ public class Page {
followers = new ArrayList<User>(); followers = new ArrayList<User>();
postsInPage = new ArrayList<Post>(); 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 //SETTERS
public void setTitle(String title) { public void setTitle(String title) {
this.title = (title != null) ? title : "no title"; this.title = (title != null) ? title : "no title";
...@@ -27,11 +35,11 @@ public class Page { ...@@ -27,11 +35,11 @@ public class Page {
} }
public void setFollowers(ArrayList<User> followers) { 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) { public void setPostsInPage(ArrayList<Post> posts) {
if(posts != null && !posts.isEmpty() ) postsInPage = posts; posts = (posts != null)? postsInPage : new ArrayList<Post>();
} }
//GETTERS //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 { ...@@ -19,25 +19,26 @@ public class PrivateUser extends User {
public PrivateUser(String nameAndSurname, String username, String password, ArrayList<Post> posts, ArrayList<User> followers) { public PrivateUser(String nameAndSurname, String username, String password, ArrayList<Post> posts, ArrayList<User> followers) {
super(nameAndSurname, username, password); super(nameAndSurname, username, password);
this.posts = (posts != null)? posts : new ArrayList<Post>(); setPosts(posts);
this.followers = (followers != null)? followers : new ArrayList<User>(); setFollowers(followers);
} }
//SETTERS //SETTERS
public void setUser(User user) {
if(user != null) { // public void setUser(User user) {
this.setNameAndSurname(user.getNameAndSurname()); // if(user != null) {
this.setUsername(user.getUsername()); // this.setNameAndSurname(user.getNameAndSurname());
this.setPassword(user.getPassword()); // this.setUsername(user.getUsername());
} // this.setPassword(user.getPassword());
} // }
// }
public void setPosts(ArrayList<Post> posts) { 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) { public void setFollowers(ArrayList<User> followers) {
if(followers != null) this.followers = followers; this.followers = (followers != null)? followers : new ArrayList<User>();
} }
//GETTERS //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