Last active
January 27, 2016 07:01
-
-
Save Atsumi3/2c5dc3195458b038a287 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
// Factory Method | |
public interface Human { | |
String getName(); | |
} | |
/// Tanaka Factory | |
sealed class TanakaImpl : Human { | |
public string getName() { | |
return "Tanaka"; | |
} | |
} | |
sealed public class TanakaFactory { | |
public static Human getInstance() { | |
return new TanakaImpl(); | |
} | |
} | |
/// Tanaka Factory | |
sealed class YamadaImpl : Human { | |
public string getName() { | |
return "Yamada"; | |
} | |
} | |
sealed public class YamadaFactory { | |
public static Human getInstance() { | |
return new YamadaImpl(); | |
} | |
} | |
Human human = TanakaFactory.getInstance(); | |
Console.WriteLine(human.getName()); // Tanaka | |
human = YamadaFactory.getInstance(); | |
Console.WriteLine(human.getName()); // Yamada |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment