Created
September 25, 2019 10:25
-
-
Save muchirijane/4608d61ea141c3dbcf19c0775b56f3a4 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
// All about class construtor and how to use this. | |
void main(){ | |
Human jenny = Human(height: 15, weight: 3.4); | |
//jenny.talk('Mommy'); | |
print(jenny.height); | |
print(jenny.weight); | |
Human james = Human(height: 20, weight: 4.2); | |
print(james.height); | |
print(james.weight); | |
// Human james = Human(20); | |
// print(james.height); | |
} | |
class Human { | |
double height; | |
double weight; | |
int age = 0; | |
Human({this.height, this.weight}); | |
// or | |
// Human({double height, double weight}){ | |
// this.height = height; | |
// this.weight = weight; | |
// } | |
void talk(String whatToSay){ | |
print(whatToSay); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment