Last active
June 14, 2021 20:41
-
-
Save AdelDaniel/5adb23850ae93c201ec46babc335521c to your computer and use it in GitHub Desktop.
this code to show the diff between extend the abstract class and the implementation of it (In dart programming Language)
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
| /* | |
| Dart Abstraction? | |
| 1- Nothing called interface in dart (Interface class) | |
| 2- you can only make abstract classes | |
| 3- NO keyword of abstract before method Declaration | |
| 4- abstract classes may contains concrete methods and abstract methods | |
| 5- abstract methods with no body | |
| 6-Normal methods has body | |
| 7- normal classes all of it methods are concrete only | |
| 8- if i “extend” the abstract class i must => override only methods without body | |
| class V1 extends good{} | |
| 9- if i “implements” the abstract class i must override “all methods” | |
| => with body and without body | |
| class V2 implements good{} | |
| */ | |
| abstract class good{ | |
| int getint(); | |
| void printInt(){ | |
| print("int is printed"); | |
| } | |
| } | |
| class V1 extends good{ | |
| @override | |
| int getint()=>4; | |
| } | |
| class V2 implements good{ | |
| @override | |
| int getint()=>10; | |
| @override | |
| void printInt(){ | |
| print("must be imp"); | |
| } | |
| } | |
| void main() { | |
| V1 v1 = V1(); | |
| print(v1.getint()); | |
| v1.printInt(); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment