Last active
July 7, 2020 09:50
-
-
Save Tiorzfk/2fe4a33a05037257fd28eaaa1fc45630 to your computer and use it in GitHub Desktop.
(Facade) Langkah pembuatan : 1. Interface LaptopShop.java 2. Asus.java, Lenovo.java, Acer.java 3. Facade Class ShopKeeper.java 4. FacadePatternClient.java
This file contains 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 Acer implements LaptopShop { | |
@Override | |
public void modelNo() { | |
System.out.println("Acer Aspire ES1"); | |
} | |
@Override | |
public void price() { | |
System.out.println("Rp. 3.000.000"); | |
} | |
} |
This file contains 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 Asus implements LaptopShop{ | |
@Override | |
public void modelNo() { | |
System.out.println("ASUS X455LA"); | |
} | |
@Override | |
public void price() { | |
System.out.println("Rp. 5.000.000"); | |
} | |
} |
This file contains 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 FacadePatternClient { | |
public static void main(String[] args) { | |
ShopKeeper sk = new ShopKeeper(); | |
sk.asusSale(); | |
sk.lenovoSale(); | |
sk.acerSale(); | |
} | |
} |
This file contains 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 LaptopShop { | |
public void modelNo(); | |
public void price(); | |
} |
This file contains 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 Lenovo implements LaptopShop { | |
@Override | |
public void modelNo() { | |
System.out.println("Lenovo Ideapad"); | |
} | |
@Override | |
public void price() { | |
System.out.println("Rp. 3.000.000"); | |
} | |
} |
This file contains 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 ShopKeeper { | |
private LaptopShop asus; | |
private LaptopShop lenovo; | |
private LaptopShop acer; | |
public ShopKeeper() { | |
asus = new Asus(); | |
lenovo = new Lenovo(); | |
acer = new Acer(); | |
} | |
public void asusSale() { | |
asus.modelNo(); | |
asus.price(); | |
} | |
public void lenovoSale() { | |
lenovo.modelNo(); | |
lenovo.price(); | |
} | |
public void acerSale() { | |
acer.modelNo(); | |
acer.price(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment