Last active
October 12, 2024 10:11
-
-
Save gyugyu90/95080fed9fa2704fccc83317b317eacd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
abstract class Language { | |
factory Language(String languageCode) { | |
if (languageCode == 'ko') { | |
return Korean(); | |
} | |
return English(); | |
} | |
void sayHello(); | |
} | |
class Korean implements Language { | |
@override | |
void sayHello() { | |
print('안녕하세요'); | |
} | |
} | |
class English implements Language { | |
@override | |
void sayHello() { | |
print('Hello'); | |
} | |
} | |
void main() { | |
Language('ko').sayHello(); // 안녕하세요 | |
Language('en').sayHello(); // Hello | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment