0% found this document useful (0 votes)
4 views2 pages

CSS 116. Activity 1

The document outlines the requirements for developing an online payment system using object-oriented principles in Java. It specifies an abstract class 'Payment' with properties and methods, an interface 'Refundable', and three classes for different payment types: 'CreditCardPayment', 'DebitCardPayment', and 'WalletPayment'. Additionally, a client class 'PaymentSystem' is described to manage payment objects and perform operations like adding, processing, and refunding payments.

Uploaded by

begaly.adil1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

CSS 116. Activity 1

The document outlines the requirements for developing an online payment system using object-oriented principles in Java. It specifies an abstract class 'Payment' with properties and methods, an interface 'Refundable', and three classes for different payment types: 'CreditCardPayment', 'DebitCardPayment', and 'WalletPayment'. Additionally, a client class 'PaymentSystem' is described to manage payment objects and perform operations like adding, processing, and refunding payments.

Uploaded by

begaly.adil1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CSS 116 Programming Fundamentals (Java) II

Activity 1

Problem: Online Payment System


Problem Statement:
You are tasked with developing a system for managing online payments. The system handles
different types of payments such as Credit Card, Debit Card, and Wallet payments. Each
payment type has unique behavior but must adhere to common payment processes. Implement
this system using object-oriented principles.

Requirements:
1.​ Abstract Class: Payment
○​ Represents a generic payment.
○​ Properties:
■​ amount (double)
■​ transactionId (String)
○​ Constructor: Initializes the amount and generates a unique transactionId.
○​ Abstract Method:
■​ processPayment() (void) – Must be implemented by subclasses to
define how the payment is processed.
○​ Non-Abstract Methods:
■​ displayDetails() – Prints the transaction details in the format:​
"Transaction ID: <transactionId>, Amount: <amount>".

2.​ Interface: Refundable


○​ Methods:
■​ refund() (void) – Defines a refund process for eligible payments.

3.​ Classes:
○​ CreditCardPayment (inherits Payment, implements Refundable)
■​ Extra Property: cardNumber (String)
■​ Implements processPayment(): Prints "Processing credit card
payment of <amount>".
■​ Implements refund(): Prints "Refunding credit card payment
for transaction <transactionId>".
○​ DebitCardPayment (inherits Payment, implements Refundable)
■​ Extra Property: cardNumber (String)
■​ Implements processPayment(): Prints "Processing debit card
payment of <amount>".
■​ Implements refund(): Prints "Refunding debit card payment
for transaction <transactionId>".
○​ WalletPayment (inherits Payment)
■​ Extra Property: walletProvider (String)
■​ Implements processPayment(): Prints "Processing wallet
payment of <amount> via <walletProvider>".

4.​ Client Class: PaymentSystem


○​ Use an ArrayList to store different payment objects.
○​ Allow the user to:
■​ Add payments (CreditCardPayment, DebitCardPayment, or
WalletPayment) to the list.
■​ Process all payments by iterating through the ArrayList.
■​ Refund eligible payments (CreditCardPayment and
DebitCardPayment).

You might also like