Created with <3 with dartpad.dev.
Created
June 19, 2023 20:32
-
-
Save onumanfj/32172191136ae9b9abc0c64a714680f4 to your computer and use it in GitHub Desktop.
dart - classes and objects
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
void main() { | |
//objects | |
Human yaw = Human(5.9); | |
print(yaw.height); | |
// Humaniod francios = Humaniod(); | |
// print(francios.height); | |
// francios.height = 5.9; | |
// print(francios.height); | |
// francios.talk('Hello world!'); | |
} | |
class Human { | |
//constructors | |
Human(double startingHeight) { | |
height = startingHeight; | |
} | |
//properties | |
late double height; | |
int age = 18; | |
//methods | |
void talk(String whatToSay) { | |
print(whatToSay); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment