Controls the use of many Facade classes. user uses classes under Facade through Facade </ font>
Check with the following class structure
package | Access modifier | class | Explanation |
---|---|---|---|
sample | public | facade.class | Control the calling and usage of each class managed by facade |
sample | default | sam0.class~sam2.class | returns an int value |
default | public | user(Main.class) | sam0 using facade.class~sam2.Use class |
facade.class
package sample;
public class facade{
int res;
public facade(int condition){
switch(condition){
case 0 : res = new sam0().get();break;
case 1 : res = new sam1().get();break;
default : res = new sam2().get();break;
}
this.res = res;
}
public int get(){return this.res;}
}
sam01.class
package sample;
class sam0{ int get(){return 0;} }
class sam1{ int get(){return 1;} }
class sam2{ int get(){return 2;} }
user(Main.class)
import sample.facade;
class Main {
public static void main(String[] args){
facade fd = new facade(8);
System.out.println(fd.get());
}
}
Recommended Posts