SageTheWizard

Movie.java

Feb 24th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.87 KB | None | 0 0
  1. /*
  2.   Author: Jacob Gallucci
  3.   Course: CMPSC 221
  4.   Assignment: Programming Assignment 2 - Movie Database - Movie super class
  5.   Due date: 2/27/2018
  6.   File: Movie.java
  7.   Purpose: Movie object (super class) - Contains constructs (default and non-default), Private title, ratings, genre, director and star
  8.                                         strings, set methods and get methods
  9.   Compiler/IDE: OpenJDK 1.8.0_151 (compiled from CLI) - Atom / Vim text editors
  10.   Operating system: Debian Stretch 9
  11.   Reference(s):  I referenced my project 1 Question.java to make sure everything was okay when setting up the object
  12.  
  13. */
  14. public class Movie
  15. {
  16.   private String title;
  17.   private String rating;
  18.   private String genre;
  19.   private String director;
  20.   private String star;
  21.  
  22.   public Movie() // Initializes the movie object if no input is given
  23.   {
  24.     title = "";
  25.     rating = "";
  26.     genre = "";
  27.     director = "";
  28.     star = "";
  29.  
  30.   }
  31.   public Movie(String name, String rate, String type, String direct, String act) // initializes movie object if input is given
  32.   {
  33.     title = name;
  34.     rating = rate;
  35.     genre = type;
  36.     director = direct;
  37.     star = act;
  38.   }
  39.   public void setTitle(String name) // sets the private title string to inputted name
  40.   {
  41.     title = name;
  42.   }
  43.   public void setRating(String rate) // sets the private rating to inputed rating
  44.   {
  45.     rating = rate;
  46.   }
  47.   public void setGenre(String type) // sets the private genre to the inputted genre
  48.   {
  49.     genre = type;
  50.   }
  51.   public void setDirector(String direct) // sets the private director to the inputted director
  52.   {
  53.     director = direct;
  54.   }
  55.   public void setStar(String act)  // Sets the private star to the inputted star
  56.   {
  57.     star = act;
  58.   }
  59.   public String getTitle() // Returns the private title as a string
  60.   {
  61.     return title;
  62.   }
  63.   public String getRating() // returns the private rating as a string
  64.   {
  65.     return rating;
  66.   }
  67.   public String getGenre() // returns the private genre as a string
  68.   {
  69.     return genre;
  70.   }
  71.   public String getDirector() // returns the private director as a string
  72.   {
  73.     return director;
  74.   }
  75.   public String getStar() // returns private star as a string
  76.   {
  77.     return star;
  78.   }
  79.   public boolean equals(Movie compare) // Compares two movie titles to see if they are the same
  80.   {
  81.     return ((title.equalsIgnoreCase(compare.title)) & (rating.equalsIgnoreCase(compare.rating)) &
  82.             (genre.equalsIgnoreCase(compare.genre)) & (director.equalsIgnoreCase(compare.director)) &
  83.             (star.equalsIgnoreCase(compare.star)));
  84.  
  85.   }
  86.   public String toString() // returns a string that outputs all elements of the movie  object
  87.   {
  88.     return ("Title: " + getTitle() + "\nRating: " + getRating() + "\nGenre: " + getGenre() + "\nDirector: " + getDirector() +
  89.             "\nStar: " + getStar() + "\n");
  90.   }
  91. }
Add Comment
Please, Sign In to add comment