Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public interface MainIfc {}
- class Ifc1 implements MainIfc {
- private String a1;
- public String getA1() {
- return a1;
- }
- public void setA1(String a1) {
- this.a1 = a1;
- }
- }
- class Ifc2 implements MainIfc {
- private String x1;
- private String x2;
- public String getX1() {
- return x1;
- }
- public void setX1(String x1) {
- this.x1 = x1;
- }
- public String getX2() {
- return x2;
- }
- public void setX2(String x2) {
- this.x2 = x2;
- }
- }
- public class GetIfc {
- public Class getIfcType(int code) {
- if (code==1)
- return Ifc1.class;
- else
- return Ifc2.class;
- }
- public MainIfc getIfc(int code) {
- if (code==1) {
- Ifc1 thisIfc = new Ifc1();
- thisIfc.setA1("Ifc1");
- return thisIfc;
- } else {
- Ifc2 thisIfc = new Ifc2();
- thisIfc.setX1("Ifc2");
- thisIfc.setX2("Ifc2");
- return thisIfc;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement