Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
27 views
3 pages
04 Task Performance 1 - ARG1
N/A
Uploaded by
Luis Valencia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download
Save
Save 04 Task Performance 1 - ARG1 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
27 views
3 pages
04 Task Performance 1 - ARG1
N/A
Uploaded by
Luis Valencia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save 04 Task Performance 1 - ARG1 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save 04 Task Performance 1 - ARG1 For Later
You are on page 1
/ 3
Search
Fullscreen
Name: Luis Adrian S.
Valencia
Section: BT501
CODE
public interface Payment {
void pay(double amount); // Method signature without body
public class Online implements Payment {
private String email;
private String password;
public Online(String email, String password) {
this.email = email; // Assigning email to the class variable
this.password = password; // Assigning password to the class variable
@Override
public void pay(double amount) {
System.out.println("Paid using online account: " + amount);
public class Mobile implements Payment {
private String number;
private int pin;
public Mobile(String number, int pin) {
this.number = number; // Assigning number to the class variable
this.pin = pin; // Assigning pin to the class variable
}
@Override
public void pay(double amount) {
System.out.println("Paid using mobile wallet: " + amount);
public class Cart {
private double amount;
public Cart(double amount) {
this.amount = amount; // Assigning amount to the class variable
public void pay(Payment mode) {
mode.pay(amount); // Calling the pay method of the provided Payment
mode
public class TestStrategy {
public static void main(String[] args) {
Cart cart = new Cart(1512.75);
cart.pay(new Online("
[email protected]
", "Wasd8456!")); //
Online payment
cart = new Cart(375.25);
cart.pay(new Mobile("1234567890", 1234)); // Mobile payment
}
OUTPUT
You might also like
c11 - Lab Task Two
PDF
No ratings yet
c11 - Lab Task Two
2 pages
QQQ
PDF
0% (3)
QQQ
8 pages
PBL Report On Java
PDF
No ratings yet
PBL Report On Java
28 pages
Inheritance, Overloading and Overriding: Recall
PDF
No ratings yet
Inheritance, Overloading and Overriding: Recall
21 pages
Class and Object
PDF
No ratings yet
Class and Object
74 pages
Oop CLASS Ass # 3
PDF
No ratings yet
Oop CLASS Ass # 3
23 pages
Programs Lab-2
PDF
No ratings yet
Programs Lab-2
10 pages
Java NOTE
PDF
No ratings yet
Java NOTE
13 pages
Exam Notes2
PDF
No ratings yet
Exam Notes2
13 pages
Oop Assignment
PDF
No ratings yet
Oop Assignment
22 pages
ITP Activity Module 12
PDF
No ratings yet
ITP Activity Module 12
7 pages
Week 12 Activity
PDF
No ratings yet
Week 12 Activity
7 pages
Ooad 4
PDF
No ratings yet
Ooad 4
18 pages
TP in Software Design
PDF
No ratings yet
TP in Software Design
4 pages
A Bank Account Class
PDF
No ratings yet
A Bank Account Class
10 pages
JAVA Account Class Assignment
PDF
No ratings yet
JAVA Account Class Assignment
6 pages
Bilal Rafique
PDF
No ratings yet
Bilal Rafique
8 pages
2.1 Pratice
PDF
No ratings yet
2.1 Pratice
5 pages
Class and Objects
PDF
No ratings yet
Class and Objects
5 pages
Abdullah
PDF
No ratings yet
Abdullah
13 pages
04 Task Performance (4) Jeyell Mags
PDF
No ratings yet
04 Task Performance (4) Jeyell Mags
2 pages
BankAccount Class Classes and Objects Summary
PDF
No ratings yet
BankAccount Class Classes and Objects Summary
4 pages
Practical OOP
PDF
No ratings yet
Practical OOP
25 pages
Exercises AdapterPattern Solution 2
PDF
No ratings yet
Exercises AdapterPattern Solution 2
6 pages
NPConstructors Programs
PDF
No ratings yet
NPConstructors Programs
6 pages
Computer Project ISC
PDF
No ratings yet
Computer Project ISC
51 pages
SDlabexercise
PDF
No ratings yet
SDlabexercise
3 pages
NIMIEXP4JAVA
PDF
No ratings yet
NIMIEXP4JAVA
7 pages
Polymorphism OOP
PDF
No ratings yet
Polymorphism OOP
8 pages
Q016 - Product Payment by Overloading
PDF
No ratings yet
Q016 - Product Payment by Overloading
4 pages
Oop Sol
PDF
No ratings yet
Oop Sol
10 pages
Name: Ridhima Srivastava Uid: 2024200126 Experiment No. 7b Aim: Program 1 Problem Statement
PDF
No ratings yet
Name: Ridhima Srivastava Uid: 2024200126 Experiment No. 7b Aim: Program 1 Problem Statement
14 pages
Particip5 2
PDF
No ratings yet
Particip5 2
4 pages
XNXNX
PDF
No ratings yet
XNXNX
4 pages
Exp (5) - 1
PDF
No ratings yet
Exp (5) - 1
4 pages
CC4001 Programming Engineering
PDF
No ratings yet
CC4001 Programming Engineering
6 pages
Abstract Class Codes
PDF
No ratings yet
Abstract Class Codes
11 pages
2023 Table
PDF
No ratings yet
2023 Table
7 pages
Assignment 1-2
PDF
No ratings yet
Assignment 1-2
1 page
Bank
PDF
No ratings yet
Bank
2 pages
A.antony Oop Lab Sheet 3
PDF
No ratings yet
A.antony Oop Lab Sheet 3
5 pages
Basic Class Diagram Code Final
PDF
No ratings yet
Basic Class Diagram Code Final
10 pages
Abstract Class - Example 2
PDF
No ratings yet
Abstract Class - Example 2
3 pages
TRAINING
PDF
No ratings yet
TRAINING
14 pages
Chanbgee
PDF
No ratings yet
Chanbgee
2 pages
Chapter 6 - Account Solution
PDF
No ratings yet
Chapter 6 - Account Solution
3 pages
Week 9 Lecture 3 - Payment System Demo
PDF
No ratings yet
Week 9 Lecture 3 - Payment System Demo
3 pages
1 ST
PDF
No ratings yet
1 ST
1 page
Lecture 9
PDF
No ratings yet
Lecture 9
15 pages
User Java
PDF
No ratings yet
User Java
2 pages
CSS 116. Activity 1
PDF
No ratings yet
CSS 116. Activity 1
2 pages
Assignment
PDF
No ratings yet
Assignment
4 pages
04 Task Performance 1
PDF
No ratings yet
04 Task Performance 1
2 pages
Assignment 11
PDF
No ratings yet
Assignment 11
2 pages
Q - No2 - 24P-3024 - Atta Ul Mustafa - Assignment No 2
PDF
No ratings yet
Q - No2 - 24P-3024 - Atta Ul Mustafa - Assignment No 2
3 pages
Lab 10 97
PDF
No ratings yet
Lab 10 97
2 pages
Software Design Simplified
From Everand
Software Design Simplified
Liviu Catalin Dorobantu
No ratings yet
Stripe Integration in Angular: A Step-by-Step Guide to Creating Payment Functionality
From Everand
Stripe Integration in Angular: A Step-by-Step Guide to Creating Payment Functionality
Abdelfattah Ragab
No ratings yet
Angular Reactive Forms: Everything you need to know
From Everand
Angular Reactive Forms: Everything you need to know
Abdelfattah Ragab
No ratings yet
Core Java Programming Book
From Everand
Core Java Programming Book
Manish Soni
No ratings yet