Skip to content

Instantly share code, notes, and snippets.

@yujuwon
Created January 24, 2013 04:15
Show Gist options
  • Save yujuwon/4617571 to your computer and use it in GitHub Desktop.
Save yujuwon/4617571 to your computer and use it in GitHub Desktop.
public interface Bark{
String GetSound();
}
public class Dog implements Bark{
@Override
public String GetSound(){
return "멍멍";
}
}
public class Cat implements Bark{
@Override
public String GetSound(){
return "야옹";
}
}
public class Factory{
public static Bark getInstance(String key){
if("개".equals(key)){
return new Dog();
}
if("고양이".equals(key)){
return new Cat();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment