Created
February 23, 2016 14:42
-
-
Save bananu7/67d63ff407579953414c to your computer and use it in GitHub Desktop.
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
package com.company; | |
abstract class A { | |
public abstract void hello(); | |
} | |
abstract class B extends A { | |
} | |
class C extends B { | |
public void hello() { | |
System.out.println("hello world"); | |
} | |
} | |
interface IFactory { | |
A factorize(); | |
} | |
abstract class AbstractFactory implements IFactory { | |
String dup(String s) { | |
return s + s; | |
} | |
} | |
class CFactory extends AbstractFactory { | |
public A factorize() { | |
return new C(); | |
} | |
} | |
class HelloFacade { | |
public void hello() { | |
IFactory f = new CFactory(); | |
A a = f.factorize(); | |
a.hello(); | |
} | |
} | |
public class Main { | |
public static void main(String[] args) { | |
HelloFacade f; | |
f.hello(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment