Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: Jacob Gallucci
- E-mail: [email protected]
- Course: CMPSC 221
- Assignment: Programming Assignment 2 - Movie Database - Movie super class
- Due date: 2/27/2018
- File: Movie.java
- Purpose: Movie object (super class) - Contains constructs (default and non-default), Private title, ratings, genre, director and star
- strings, set methods and get methods
- Compiler/IDE: OpenJDK 1.8.0_151 (compiled from CLI) - Atom / Vim text editors
- Operating system: Debian Stretch 9
- Reference(s): I referenced my project 1 Question.java to make sure everything was okay when setting up the object
- */
- public class Movie
- {
- private String title;
- private String rating;
- private String genre;
- private String director;
- private String star;
- public Movie() // Initializes the movie object if no input is given
- {
- title = "";
- rating = "";
- genre = "";
- director = "";
- star = "";
- }
- public Movie(String name, String rate, String type, String direct, String act) // initializes movie object if input is given
- {
- title = name;
- rating = rate;
- genre = type;
- director = direct;
- star = act;
- }
- public void setTitle(String name) // sets the private title string to inputted name
- {
- title = name;
- }
- public void setRating(String rate) // sets the private rating to inputed rating
- {
- rating = rate;
- }
- public void setGenre(String type) // sets the private genre to the inputted genre
- {
- genre = type;
- }
- public void setDirector(String direct) // sets the private director to the inputted director
- {
- director = direct;
- }
- public void setStar(String act) // Sets the private star to the inputted star
- {
- star = act;
- }
- public String getTitle() // Returns the private title as a string
- {
- return title;
- }
- public String getRating() // returns the private rating as a string
- {
- return rating;
- }
- public String getGenre() // returns the private genre as a string
- {
- return genre;
- }
- public String getDirector() // returns the private director as a string
- {
- return director;
- }
- public String getStar() // returns private star as a string
- {
- return star;
- }
- public boolean equals(Movie compare) // Compares two movie titles to see if they are the same
- {
- return ((title.equalsIgnoreCase(compare.title)) & (rating.equalsIgnoreCase(compare.rating)) &
- (genre.equalsIgnoreCase(compare.genre)) & (director.equalsIgnoreCase(compare.director)) &
- (star.equalsIgnoreCase(compare.star)));
- }
- public String toString() // returns a string that outputs all elements of the movie object
- {
- return ("Title: " + getTitle() + "\nRating: " + getRating() + "\nGenre: " + getGenre() + "\nDirector: " + getDirector() +
- "\nStar: " + getStar() + "\n");
- }
- }
Add Comment
Please, Sign In to add comment