Java Programming: \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\Driver.java\\\\\\\\\\\\\\\\\
ID: 3679677 • Letter: J
Question
Java Programming:
\\\\\\\\Driver.java\\\\\\\\
public class Driver {
public static void main(String[] args) {
ActionMovie killbill2 = new ActionMovie(0, "Kill Bill: Volume 2", "R");
ComedyMovie meangirls = new ComedyMovie(1, "Mean Girls", "PG-13");
System.out.println("If " + killbill2.getTitle()
+ " is 2 days late the fee is " + killbill2.calcLateFees(2));
System.out.println("If " + killbill2.getTitle()
+ " is 3 days late the fee is " + killbill2.calcLateFees(3));
System.out.println("If " + meangirls.getTitle()
+ " is 3 days late the fee is " + meangirls.calcLateFees(3));
}
}
Explanation / Answer
MOvie class:
import java.util.*;
public class Movie
{
String rating = null;
String title = null;
int ID = 0;
int rentTime;
double lateFee;
double Fee;
public Movie(String theTitle, String theRating, int theID, int theRentTime)
{
setRating(theRating);
setTitle(theTitle);
setID(theID);
setRentTime(theRentTime);
}
public String getRating()
{
return rating;
}
public void setRating(String theRating)
{
if (theRating != null)
{
rating = theRating;
}
}
public String getTitle()
{
return title;
}
public void setTitle(String theTitle)
{
if (theTitle != null)
{
title = theTitle;
}
}
public int getID()
{
return ID;
}
public void setID(int theID)
{
if (theID > 0)
{
ID = theID;
}
}
public int getRentTime()
{
return rentTime;
}
public void setRentTime(int theRentTime)
{
if (theRentTime > 0)
{
rentTime = theRentTime;
}
}
public int equals(int theID)
{
if (ID == theID)
{
System.out.println("Movies are identical.");
}
return ID;
}
public double calcLateFees(double lateFee, int rentTime, double Fee)
{
if (rentTime > 1)
{
Fee = (rentTime * lateFee);
}
return Fee;
}
public void MovieDetails()
{
System.out.println("The movie title is " + title + ". The rating is " + rating + ". The ID is " + ID + ".");
System.out.println("The late fee cost is: " + Fee + ".");
}
public static void main(String[] args)
{
Movie rental1 = new Comedy("FAST AND FURIOUS", "20", 5682658, 3, "ACTION");
Movie rental2 = new Action("KILL BILL:", "PG 25", 223456789, 5, "Action");
Movie rental3 = new Drama("Dispicable Me", "G", 243534, 7, "DramA");
System.out.println("Rental1 details:");
rental1.MovieDetails();
System.out.println("Rental2 details:");
rental2.MovieDetails();
System.out.println("Rental3 details:");
rental3.MovieDetails();
}
}
Action class:
import java.util.*;
public class Action extends Movie
{
String Genre = null;
double lateFee = 3;
int rentTime;
double Fee;
public Action(String theRating, String theTitle, int theID, int theRentTime, String theGenre)
{
super(theRating, theTitle, theID, theRentTime);
setGenre(theGenre);
}
public String getGenre()
{
return Genre;
}
public void setGenre(String theGenre)
{
if (theGenre != null)
{
Genre = theGenre;
}
}
public double calcLateFees(double lateFee, int rentTime, double Fee)
{
if (rentTime > 1)
{
Fee = (rentTime * lateFee);
}
return Fee;
}
public void MovieDetails()
{
System.out.println("The movie title is: " + title + ". The rating is: " + rating + ". The ID is: " + ID + ". The rent time is: " + rentTime + ". The genre is: " + Genre + ".");
System.out.println("The late fee costs are: " + Fee + ".");
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.