Last active
February 8, 2020 12:08
-
-
Save angwandi/fa42a935747488f4e77cf682bf30fbf7 to your computer and use it in GitHub Desktop.
class and object in Dart
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
void main(){ | |
//dema is the actual objet | |
Human dema = Human(height:15,age:12); | |
print(dema.height); | |
dema.talk('Why is the sky blue??'); | |
Human innocent = Human(height: 1.6,age:30); | |
print(innocent.height); | |
} | |
//blueprint of all humans | |
class Human{ | |
//class feilds or properties : variables associated to the class | |
double height; | |
int age; | |
//class constructor : initialize the values of class properties | |
Human({this.height,this.age}); | |
//class methode : method associated to the class | |
void talk(String whatToSay){ | |
print(whatToSay); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment