Skip to content

Instantly share code, notes, and snippets.

@csabatini
Last active February 21, 2019 14:15
Show Gist options
  • Save csabatini/5424338 to your computer and use it in GitHub Desktop.
Save csabatini/5424338 to your computer and use it in GitHub Desktop.
Movie.java
/** PROGRAM ASSIGNMENT 5 Movie.java
*
* Program Description
* This is the Movie class, which includes instance variables and instance
* methods that describe the Movie abstract data type.
*
*/
package library.films;
public abstract class Movie implements Profitable {
/* Declare private instance variables */
private String title;
private String director;
private int year;
private double productionCost;
/* Declare private static variables */
private static int totalMovies = 0;
/* No-arg construct for the Movie class */
public Movie() {
totalMovies++;
}
/* Alternate constructor for the Movie class */
public Movie(String title, String director, int year,
double productionCost) {
this.title = title;
this.director = director;
this.year = year;
this.productionCost = productionCost;
totalMovies++;
}
/* Accessor method for title data field */
public String getTitle() {
return title;
}
/* Mutator method for title data field */
public void setTitle(String title) {
this.title = title;
}
/* Accessor method for director data field */
public String getDirector() {
return director;
}
/* Mutator method for director year field */
public void setDirector(String director) {
this.director = director;
}
/* Accessor method for year data field */
public int getYear() {
return year;
}
/* Mutator method for year data field */
public void setYear(int year) {
this.year = year;
}
/* Accessor method for production cost data field */
public double getProductionCost() {
return productionCost;
}
/* Mutator method for production cost data field */
public void setProductionCost(double productionCost) {
this.productionCost = productionCost;
}
/* Accessor method for totalMovies class variable */
public static int getTotalMovies() {
return totalMovies;
}
/* toString effector method to output contents of a Movie object */
public String toString() {
return "Movie " + title + " was directed by " + director + " in " +
year + " with production \ncost of " + productionCost + " million.";
}
/** Abstract method getCategory*/
public abstract String getCategory();
/** Abstract method calcRevenue*/
public abstract double calcRevenue();
/** Abstract method calcProfit*/
public abstract double calcProfit();
} // end of class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment