A class called Payment
Define a class called Payment which contains an instance variable of type double that stores the
amount of a payment. Include appropriate getter/setter methods in your class. Include a method
named paymentDetails which outputs an English sentence describing the payment.
Next define a class named CashPayment which is derived from Payment. The class should redefine the
paymentDetails method to indicate that the payment is cash. Include necessary constructors for this
class.
In addition to this, define a third class called CreditCardPayment that is derived from Payment. This
class should contain instance variables for the:
• Cardholder’s Name
• Expiration Date
• Credit Card Number
Lastly modify the paymentDetails method on this class to include all credit card information in the
printout. Include a main method in your submission (either in one of the three classes or in a separate
class) which demonstrates two instances of CashPayment and at least two instances of
CreditCardPayment and the different values of paymentDetails for each.
Save your submissions in Payment.java, CashPayment.java and CreditCardPayment.java.
Exercise #2 – Movie Problem (10pts)
Consider a movie rental business. Create a class named Movie which can be used for your video rental
business. The Movie class should track the following:
• Motion Picture Association of America Rating (e.g. Rated G, PG-13, R)
• ID number
• Movie title
Ensure appropriate getter/setter methods in your class definition. Create an equals() method (which
overrides java.lang.Object’s method), where two movies objects are equal if their ID number is
identical.
Next, create three additional classes named Action, Comedy and Drama which are each derived from
Movie. Lastly create an overridden method named calculateLateFees which takes input a number of
days the movie is late and returns the late fee for that movie. The default fee is $2 a day. Action
movies have a fee of $3 per day, comedies are $2.50 per day, and dramas are $2 per day. Test your
classes with a main method, either inside one of the classes or inside a class of its own.
Save your submission in Movie.java, Action.java, Comedy.java, and Drama.java.
Exercise #3 – Shape Problem (20pts)
Create an interface named Shape with the following method signature:
double area();
Next define classes which implement this interface as follows:
• Circle, with instance data for the radius, a constructor which sets the radius and appropriate
getter/setter methods
• Rectangle, with instance data for the length and width, a constructor which sets both properties
and appropriate getter/setter methods