Created
February 23, 2020 11:24
-
-
Save digitaljoni/5d4b8134eb09c2e6477e77a77f2e13b1 to your computer and use it in GitHub Desktop.
OOP DBZ Version
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
| class Saiyan { | |
| Saiyan({this.name, this.power}); | |
| final String name; | |
| final int power; | |
| // Methods | |
| void punch() { | |
| print('$name punched'); | |
| } | |
| void kick({int legs: 1}) { | |
| print('$name kicked using $legs legs'); | |
| } | |
| void specialMove() { | |
| // do special move | |
| } | |
| @override | |
| String toString() { | |
| return 'Saiyan $name Power Level : $power'; | |
| } | |
| } | |
| void main() { | |
| final Saiyan goku = Saiyan(name: 'Goku', power: 8000); | |
| print(goku); | |
| goku.punch(); | |
| final Saiyan vegeta = Saiyan(name: 'Vegeta', power: 6000); | |
| print(vegeta); | |
| vegeta.kick(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment