Last active
December 3, 2023 07:31
-
-
Save isaacssemugenyi/2886d1333ad192f635c28ddbfe628fed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AtPay implements Payment { | |
@Override | |
public void debitUser() { | |
System.out.println("Money deducted from user using AtPay"); | |
} | |
@Override | |
public void checkUserBalance() { | |
System.out.println("User balance checked using AtPay"); | |
} | |
@Override | |
public void creditUser() { | |
System.out.println("Account credited using AtPay"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ConsumeFacade { | |
public static void main(String[] args){ | |
MyFacade facade1 = new MyFacade(); | |
facade1.atChargeUser(); | |
facade1.mmChargeUser(); | |
facade1.MmPayUser(); | |
facade1.atPayUser(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyFacade { | |
private AtPay atPay; | |
private MmPay mmPay; | |
MyFacade(){ | |
atPay = new AtPay(); | |
mmPay = new MmPay(); | |
} | |
public void MmPayUser(){ | |
mmPay.creditUser(); | |
} | |
public void atPayUser(){ | |
atPay.creditUser(); | |
} | |
public void atChargeUser(){ | |
atPay.debitUser(); | |
atPay.checkUserBalance(); | |
} | |
public void mmChargeUser(){ | |
mmPay.debitUser(); | |
mmPay.checkUserBalance(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MmPay implements Payment { | |
@Override | |
public void debitUser() { | |
System.out.println("Money deducted from user using MmPay"); | |
} | |
@Override | |
public void checkUserBalance() { | |
System.out.println("User balance checked using MmPay"); | |
} | |
@Override | |
public void creditUser() { | |
System.out.println("Account credited using MmPay"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Payment { | |
void debitUser(); | |
void checkUserBalance(); | |
void creditUser(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment