Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA In this assignment, youll be modeling information about movies as well as those who direct, produce, and act in them using inheritance. In particular,

JAVA

In this assignment, youll be modeling information about movies as well as those who direct, produce, and act in them using inheritance. In particular, the assignment will have you create a base class called FilmIndustryWorker with subclasses for Actor, Director, and Producer. Your Movie class should not have any subclasses. When doing this assignment, you should strive to place all shared/common characteristics into the abstract base class and have appropriate abstract methods which all subclasses must then implement. To get started, open IntelliJ and create a new java project named asg3.

Part 1: Stubbing out a FilmIndustryWorker hierarchy Create classes for FilmIndustryWorker, Actor, Producer, and Director.

For each of these classes, youll need to define fields, getter methods, and constructors outlined below. Now do the following:

the Actor, Producer, and Director should extend FilmIndustryWorker

create a new enum by right-clicking the package ending in ist242.asg3, select New Java Class > and then select Enum from the dropdown list; name it: MovieGenre then fill it with the following values: HORROR, SCIFI, ACTION, DRAMA, ROMANCE, and COMEDY

the FilmIndustryWorker must include an abstract method called specializesInGenre which takes as a parameter a MovieGenre and returns a boolean

each subclass must call the super(..) constructor

each class should define a toString() method (its ok if you choose to only override toString() in the FilmIndustryWorker base class) Here are some details on what each class should store. The Director should be able to store:

first and last name the number of years active in the film industry

list of awards won (this can just be a list of strings)

whether or not they use digital or film technologies

The specializesInGenre(..) method for the director should only return true if the movie genre passed into the method is romance, comedy, horror, action, or drama; they can specialize in sci-fi, but only if they employ digital film technologies.

The Producer should be able to store:

first and last name

the number of years active in the film industry

list of awards won (this can just be a list of strings)

The producer can produce films in any genre with the exception of sci-fi (they can only specialize in this if they have spent more than 5 years in the film industry).

The Actor should be able to store:

first and last name

which type of acting they specialize in; define an enum at the top of this class called ActingStyle to represent the datatype for this field; the enum should contain the values METHOD, CHARACTER, and IMPROV

a list of the awards won (this can just be a list of strings)

the number of years active in the film industry

The actor can always specialize in action and romance. They can only specialize in horror, or sci-fi if they have more than ten years of industry experience. And they can only specialize in comedy and drama if their preferred acting style is improv or character.

Part 2: Creating a Movie class

The Movie class should be able to store the following as fields:

the title of the movie,

the Director of the movie,

the Producer of the movie,

the Year in which it was released (use library java.time.Year for this),

the MPAARating of the movie,

a list of Actors starring in the movie,

and the genre of the movie (use the MovieGenre enum for this).

Info for all of these fields (except the actors list) should be passed in as parameters to the constructor and assigned to the corresponding fields described above.

In the constructor, you should also do a check to see if the director specializes in the provided genre of the movie (if they dont, then throw a new IllegalArgumentException) do the same for the producer.

Dont forget to initialize an empty list of Actors starring in the movie. This should be a private field above the constructor.

Instead of passing a list of actor objects into the constructor, provide a method called addActor(..) which takes an Actor as a parameter and returns nothing. In the method, before adding the given actor to the movies list of actors, first check to see if they specialize in the current movies genre. Throw an IllegalArgumentException if they dont. Make sure you provide getter methods so that users can access each field of the object then override the toString() method. Heres what my toString produces for the movie Terminator 2:

(1991) Terminator 2: Judgement Day - SCIFI - rated : R

Part 3: Implementing the Comparable interface for Movie objects

Now make your Movie class implement the Comparable interface. Heres the relevant change to the header for your Movie class:

public class Movie implements Comparable < Movie > { ...

Once you add this, youll need to override/implement the interfaces compareTo(..) method. Well define the natural ordering for our movies by release year. Consult class notes for a summary of the compareTo(..) method contract. Essentially, the method should take a parameter o of type Movie and should return an int x, where:

x < 0 if this movies release year comes before o.releaseYear

x == 0 if this movies release year .equals(o.releaseYear)

x > 0 if this movies release year comes after o.releaseYear Hint: for any two Year variables a and b, one can test if a comes before or after b by saying a.isBefore(b) and a.isAfter(b), respectively.

Part 4: Putting it all together in a Tester class

In your Tester class, you should define a main(..) method and instantiate at least four Movie objects with relevant information. Add each one to a list, then iterate over themprinting each. Immediately after the first loop, call:

Collections . sort ( myMovies ); // if the list is named myMovies Lastly, iterate over the movies list again to confirm whether the compareTo(..) method is working correctly. See the next page for a sample run from my Tester class.

BEFORE SORTING :

(2015) The Martian - SCI_FI - rated : PG_13

(2007) Transformers 1 - ACTION - rated : PG_13

(1994) The Shawshank Redemption - DRAMA - rated : PG_13

(2008) The Dark Knight - ACTION - rated : R

-------------------------------------

AFTER SORTING :

(1994) The Shawshank Redemption - DRAMA - rated : PG_13

(2007) Transformers 1 - ACTION - rated : PG_13

(2008) The Dark Knight - ACTION - rated : R

(2015) The Martian - SCI_FI - rated : PG_13

This is a java program. Can be done on Itellij

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago