Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial Reporting Financial Statement Analysis And Valuation A Strategic Perspective

Authors: James M. Wahlen, Stephen P. Baginski, Mark Bradshaw

9th Edition

1337614689, 1337614688, 9781337668262, 978-1337614689

More Books

Students also viewed these Operating System questions