Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 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 and the different values of paymentDetails for each. Save your submissions in Payment.java, CashPayment.java and CreditCardPayment.java
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