Question
Write three classes to represent a payment. A payment class represents a payment by the amount of money (as a double) and the date of
Write three classes to represent a payment.
A payment class represents a payment by the amount of money (as a double) and the date of the payment.
A cash payment represents a payment by the amount and date.
A credit card payment represents a payment by the amount, date, and also the name and credit card number.
In each class, include:
instance data variables
getters and setters
a toString method
In the credit card payment class, include an equals method. Two payments are logically equivalent if they have the same amount, date, name, and credit card number.
Make sure to include a driver program!
When designing your classes, consider the following.
For all required methods, your class can either include the method directly or inherit it- whichever makes sense for that method!
Think about what the parent-child relationship should be between the classes.
Think about what information should be sent as parameters and what information can be hard-coded (using constants) into a class.
Move common code as high up in the hierarchy as possible.
Use super whenever possible.
Avoid repeated code.
Follow appropriate naming and style conventions.
Follow good principals of object-oriented design and inheritance.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Here are three classes as per your requirements import javautilDate Payment class class Payment private double amount private Date date public Payment...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started