015-005-007
Type-specific Processing Method with instanceof
Hard
Problem Description
Type-specific Processing Method with instanceof
Learning Objective: Design a method that performs different processing based on object type using instanceof
Overview
Create a method that receives parent class type as parameter and performs different processing based on actual type.
Specifications
- Define Payment class and its subclasses (CashPayment, CardPayment, PointPayment)
- Implement process(Payment) method in PaymentProcessor class
- Process according to payment method and output result
Output Format
Processing cash payment: 1000 yen
Processing card payment: 2500 yen (Card: 1234-****)
Processing point payment: 500 points
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
