Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in java 1. Define a class named Payment that contains an instance variable of type double that stores the amount of the payment and appropriate
in java
1. Define a class named Payment that contains an instance variable of type double that stores the amount of the payment and appropriate get and set methods. Also create a method named paymentDetails that outputs an English sentence to describe the amount of the payment. Next, define a class named CashPayment that is derived from Payment. This class should redefine the payment Details method to indicate that the payment is in cash and the amount. Include appropriate constructor(s) Define a class named CreaditCardPayment that is derived from Payment. This clas:s should contain instance variables for the name on the card, expiration date, and card number. Include appropriate constructor(s). Finally, redefine the paymentDetails method to include all credit card information and payment amount in the printout. Define a class named DebitCardPayment that is derived from CreditCardPayment. This class should contain an instance variable for the name on the PIN. Include appropriate constructor(s). Finally, redefine the paymentDetails method to include all debit card information and payment amount in the printout. Define a class named PaymentTest class that contains a main method that declares a Payment reference variable, and creates a CashPayment object, a CreditCardPayment object and a DebitCardPayment object with different values. Assign each object to the Payment reference variable and then calls paymentDetails for each until all objects paymentDetails are called once. (5 pts)Step by Step Solution
There are 3 Steps involved in it
Step: 1
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