Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You have been hired to create a payment system that supports different kinds of payments on an e-commerce site. A previous consultant has created

You have been hired to create a payment system that supports different kinds of payments on an e-commerce site. A previous consultant has created the following abstract class to handle payments: // Payment Gateway.java public abstract class Payment Gateway ( public abstract void processPayment (double amount); public abstract void refundPayment (double amount); } You have to do the following: (a) Create a class named PayPal that extends Payment Gateway. The PayPal class should have the following methods: i. A constructor that creates a PayPal object with the specified email and password. ii. A method named processPayment that prints the message "Processing payment of (amount) with PayPal for account (email)". iii. A method named refundPayment that prints the message "Refunding payment of (amount) with PayPal for account (email)".. (b) Create a class named Credit Card that extends Payment Gateway. The Credit Card class should have the following methods: i. A constructor that creates a Credit Card objct with the specified card number and expiration date. ii. A method named processPayment that prints the message "Processing payment of (amount) with Credit Card (card number) that expires on (expiration date)". iii. A method named refundPayment that prints the message "Refunding payment of (amount) with Credit Card (card number) that expires on (expiration date)". Use the following test class to test your code: // Problemi.java public class Problem! { public static void main(String[] args) { Payment Gateway paypal - new PayPal ("john.doe@marist.edu", "password"); paypal processPayment (100.00); paypal.refundPayment (100.00); Payment Gateway credit Card new Credit Card("1234567890123456", "12/2020"); credit Card.processPayment (100.00); 1 credit Card.refundPayment (100.00);

Step by Step Solution

3.52 Rating (149 Votes )

There are 3 Steps involved in it

Step: 1

Given the below code for abstract class PaymentGateway PaymentGatewayjava public abstract class PaymentGateway public abstract void processPaymentdoub... 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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Programming questions