1.3-Object-Georienteerd-Programmeren

Facebook-ish

In this assignment you are going to recreate Facebook’s wall system.

Facebook consists of users. Each user has a user name and a real (full) name. In addition, a list of posts is kept of each user.

Each post can be of one of the following types:

There are two lists for each post. One list with comments (one consists of the user who posts the comment, the comment itself and a date/time of posting). In addition, there is one list containing the likes. This list contains the users who have liked this post.

The User class will have to contain the following methods:

The Post class will need to contain the following methods:

Example

The following code:

public static void main(String[] args) {
    // Create a couple of users
    User tristan = new User("T-POtje", "Tristan Pothoven");
    User evert = new User("EduudE", "Evert Duipmans");
    User ruud = new User("Greevmeister", "Ruud Greven");

    // Add some posts
    Post post1 = new Post("Currently teaching object oriented programming.");
    Post post2 = new ImagePost("Look! My cat ate my programming book :-)", "cat.jpg", "Clarendon");
    Post post3 = new VideoPost("Inheritance explained in 1 minute...", "inheritance.mp4", 60);
    tristan.addPost(post1);
    tristan.addPost(post2);
    evert.addPost(post3);

    // Add some likes
    post2.like(evert);
    post2.like(ruud);
    post3.like(tristan);
    post3.like(ruud);
    post3.like(evert);

    // Add some comments
    post2.addComment(new Comment(evert, "That's a very nice cat."));
    post3.addComment(new Comment(ruud, "Awesome video! I finally understand inheritance."));
    post3.addComment(new Comment(tristan, "Let's add this to the materials of the course!"));

    //Print
    System.out.println(tristan);
    System.out.println("------------------");
    System.out.println(evert);
    System.out.println("------------------");
    System.out.println(ruud);
}

Produced the following output:

Posts from Tristan Pothoven aka T-POtje:
18/MARCH/2023: Currently teaching object oriented programming. (likes: 0)
Comments: 0
ImagePost on 18/MARCH/2023: Look! My cat ate my programming book :-) (likes: 2)
Comments: 1
	EduudE: That's a very nice cat.
Image: cat.jpg (Filter: Clarendon)
------------------
Posts from Evert Duipmans aka EduudE:
VideoPost on 18/MARCH/2023: Inheritance explained in 1 minute... (likes: 3)
Comments: 2
	Greevmeister: Awesome video! I finally understand inheritance.
	T-POtje: Let's add this to the materials of the course!
Video: inheritance.mp4 (60 sec)
------------------
Posts from Ruud Greven aka Greevmeister:

Process finished with exit code 0