What instance variable(s) can you add to Imdb to track the appearances of actors in movies?

Responsive Centered Red Button

Need Help with this Question or something similar to this? We got you! Just fill out the order form (follow the link below), and your paper will be assigned to an expert to help you ASAP.

Activity Description
IMDB is a long-time Amazon subsidiary with the most extensive movie database in the world. One of the core features of IMDB is the ability to look up which actors have acted in a film, or to look up which films an actor has acted in. IMDB has tons of data, and so these features must be implemented in a way that makes these lookups fast!
You’re going to recreate these pieces of IMDB’s functionality.
You’re starting with three classes:
Movie: Represents a movie. The name field alone determines uniqueness/equality.
Actor: Represents an actor (in movies). The name field alone determines uniqueness/equality.
Imdb: The class that joins them together! You’ll be implementing methods in this class (the method declarations are there, but you’ll provide the implementations — and any instance variables you need to make it all work).
Note: IMDB refers to a “database”, which in this implementation is simply the data structure(s) you’re adding to the Imdb class. Don’t worry: there’s no actual database work here for you! (that comes later in ATA!)
Step 1: Design
In this step you’ll be thinking about how you should store the data necessary to support the methods in Imdb. What instance variable(s) can you add to Imdb to track the appearances of actors in movies? You should also consider the efficiency of your choice. Getting the actors in a movie, and getting the movies an actor acts in are our two most frequently used operations. You’ll need to ensure we can implement these so they have constant, O(1), runtimes. You may well need to make modifications to the Movie and Actor classes as well (remember that HashMap, HashSet use hashCode() and equals()!).
Think about your design
Look through each of the methods in Imdb. Each one represents a use case that you’ll need to support. Think about the preconditions, invariants, and postconditions for each use case. Also think about the edge cases!
It’s probably a good idea to write down your thinking, even if it’s just in a text file or on paper.
Now, think about what data you’ll use in Imdb: how can you store the data needed so that you can efficiently support each of the use cases represented by Imdb’s methods? See if you can achieve constant O(1) runtime for the cases where it’s possible (and think about where O(n) might be the best you can do!).
Mentally test your design
Now that you have an idea of the how to represent the movie and actor data in Imdb, think through each use case and verify that it’ll work.
Remember that the data need to be consistent no matter how you add a movie or an actor to the dataset. For example, if you’re releasing a new movie, make sure that when you get movies for the actor, that new movie shows up! This may matter more when you’re implementing logic, but it might come into play in your data design as well.
Step 2: Implement the data structure
Once you’ve made a decision, walk through each method again and make a note of how you’ll implement it. Will your implementations provide the efficiency that we need for the IMDB website?
I read the methods’ Javadocs, but I don’t understand what to use to store the data.
Remember, the data needs to be consistent no matter how you add or remove a Movie or an Actor to Imdb. For example, if you’re releasing a new Movie, make sure that on the next call to getMoviesForActor(), the new Movie is returned! This may matter more when you’re implementing logic, but it might come into play in your data design as well.
Can I use more than one data structure?
When you think you’ve got it, go ahead and add your member variable declaration(s) to the Imdb class that capture your approach. We have stubbed two Map data structures in Imdb.java that you may use. Take a moment to think about the tradeoffs between using 1 or 2 Maps, and proceed accordingly.
Movie and Actor: On equality
Before implementing much further, consider what makes a movie or actor unique. This uniqueness will be key in determining if the same thing is added to the list or whether its overwritten in the list. Let’s focus on the movie.name and actor.name attributes as being the key data to determine uniqueness/equality, so base your hashCode() and equals() methods on those in the Movie and Actor classes.
Run the test cases within the MovieTest and ActorTest classes to confirm the methods are implemented logically and correctly.
Step 3: Release a new film
Implement the releaseMovie() method, and the getActorsInMovie() method in the Imdb class.
Note that releaseMovie() will overwrite an entire movie’s entry in Imdb, so you don’t need to worry about the “old” actors associated with a movie if this is called. We don’t anticipate a movie to be released twice, but you never know. We just want the latest data.
In order to implement the getActorsInMovie() method, first use the containsKey() method to see if the movie parameter is in the set. If it is, use the get method to retrieve the set and return it. If the key is not there, throw an IllegalArgumentException.
Run the relevant unit tests by running the test cases within the ReleaseMovieTest class in IntelliJ.
You might be wondering: “If I re-release a movie, then remove a movie, am I expected to restore the older version fo the movie?” No: when a movie is removed (see below), that completely wipes away any trace of that movie from IMDB. So you don’t need to worry about keeping “versions” of each movie.
Step 4: Oops, unrelease a film!
Occasionally, IMDB knows a lot about a film before the public does and accidentally leaks some information about the cast. In order to clean up if this occurs, we need a way to remove a movie from the database completely.
Implement the removeMovie() method.
Run the relevant unit tests by running the test cases within the RemoveMovieTest class in IntelliJ.
Step 5: Add a new movie credit for an actor
Implement the tagActorInMovie() method.
Remember that if you add a new credit for an actor, that actor should show up in getActorsInMovie() for that movie.
Also think about the different states that Imdb can be in before tagActorInMovie() is called. Does the movie already have actors tagged in it? Is this the first actor tagged in the movie? Maybe it’s not the first time someone has changed Imdb.
Retrieve the set of actors from the movie passed in
If that set is null, create a new hashset. Add the actor to the new hashset and put it into the master set of Movies/Actors.
If the set is not null, add the actor to the existing set.
Run the relevant TagActorTest unit tests in IntelliJ.
Step 6: Let them bask in the glory
Implement the getMoviesForActor() method. You may find at this point that you’ll have to adjust some other methods for when a new movie is added to reach O(1) access for movies for the Actor. Verify that when a movie is released or removed, the credit for each actor is added or removed as well. This is completed in the releaseMovie() and removeMovie() methods.
Run the GetMoviesTest in IntelliJ.
Step 7: Data dump
Implement the getAllActorsInImdb(), and getTotalNumCredits() methods.
Run the DataDumpTest tests in IntelliJ.
Completion Criteria
This activity will be graded according to the following Completion Criteria:
You have decided how to store the Movie and Actor data in the Imdb class.
You have updated the Imdb class to include instance variables.
You have implemented all of the methods in the Imdb class.

How to create Testimonial Carousel using Bootstrap5

Clients' Reviews about Our Services