Lab #2: Movie Manager

We are going to develop this app according to these requirements:

Bru & Tara don’t know about programming

📘 Linux Lab#SE02-1: Movie Review and Rating

Create a Maven/Gradle Java SE Project.

Add the needed dependencies:
    Lombok
    Junit
    Java Faker

Create three Java classes to define the Model. Java SE Classes:

    Movie: The Movie class represents a movie that is being reviewed. It has the following attributes:
        title: a String representing the title of the movie
        reviews: a Set of Review objects representing the reviews that have been written for this movie
        Critic: The Critic class represents a critic who writes reviews.

    The Critic class has the following attributes:
        name: a String representing the name of the critic
        Review: The Review class represents a review of a movie written by a critic.

    The Review class has the following attributes:
        movie: a Movie object representing the movie being reviewed
        critic: a Critic object representing the critic who wrote the review
        rating: an int representing the rating given by the critic (on a scale of 1 to 5)
        comment: a String representing the comment written by the critic about the movie

With Junit dependency create unitary test to test objects and operations.

From here you should add new features once all the test are passed.
    Operations, you could think in a Manager Class o similar
    New fields/attributes and new classes
    New compositions and inherence: expand your model
    Use Factory design pattern to create new objects

Solving discussion

As a starting point, we’re going to leave the dependencies for later, let’s focus on the main requirements: the Classes, so we can have an overview of the project.
The core of this lab is based in these three classes and how are they going to interact between them.

classDiagram
    class Movie{
        -String title
        -ArrayList<Review> reviews
        -Critic critic
    }
    class Critic{
        -String name
        -Review review
    }
    class Review{
        -Movie movie
        -Critic critic
        -int rating
        -String comment
    }

Our goal is to have a data-store where we can check some movies and see their reviews, update them or even delete them. But we need to solve some discussion first: Is a movie going to have several reviews? Which class depends on which? Dependency? Inheritance? Multiplicity?

Let’s consider that any movie could have different reviews from different Critics. And one critic can review multiple movies. In that case the class diagram would go as follows:

classDiagram 
    Critic "1" *-- "*" Review: Writes
    Critic "*" *-- "*" Movie: Rates
    Review "*" --o "1" Movie: Has
    class Movie{
        -String title
        -ArrayList <Review> reviews
        -Critic critic
    }
    class Critic{
        -String name
        -ArrayList<Review> reviews
    }
    
    class Review{
        -Movie movie
        -Critic critic
        -int rating
        -String comment
    }

In order to manage the different operations we are going to create a Manager for the classes, so we can add movies, list them, update them or delete them:

classDiagram 
    Critic "1" *-- "*" Review: Writes
    Critic "*" *-- "*" Movie: Rates
    Review "*" --o "1" Movie: Has
    MovieManager -- Movie: Uses
    class Movie{
        -String title
        -ArrayList <Review> reviews
        -Critic critic
    }
    class Critic{
        -String name
        -ArrayList<Review> reviews
    }
    
    class Review{
        -Movie movie
        -Critic critic
        -int rating
        -String comment
    }

    class MovieManager {
        -Scanner scan
        -ArrayList<Movie> movies
        +addMovie()
        +updateMovie()
        +listOne()
        +listAll()
        +deleteMovie()
    }

Note

Always have in mind that what we are doing here is just aproaching the problem, trying to understand it at a surface-level, not develop its full functionality.

There’s something that I think it could be improved: I don’t see the point of a Movie having a Critic, since the review already has one. Furthermor I think is interesting to add the Director of the movie. It’s true that the requirements ask for a Critic instance in the Movie Class, but it’s also true that oftenly requirements are dumb, so I’ll make another draft because that’s what we are doing now, just approaching the problem.

classDiagram 
    Critic "1" *-- "*" Review: Writes
    Director "1" *-- "*" Movie: Makes
    Review "*" --o "1" Movie: Has
    MovieManager -- Movie: Uses
    Person <|-- Director
    Person <|-- Critic
    class Movie{
        -String title
        -ArrayList <Review> reviews
        -Director director
    }
    class Critic{
        -String name
        -ArrayList<Review> reviews
    }
    
    class Review{
        -Movie movie
        -Critic critic
        -int rating
        -String comment
    }

    class Person {
        -String name
    }

    class Director{
        -ArrayList<Movie> movies
        -int oscarQty
    }

    class MovieManager {
        -Scanner scan
        -ArrayList<Movie> movies
        +addMovie()
        +updateMovie()
        +listOne()
        +listAll()
        +deleteMovie()
    }