Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. //class object and constructor
  2. //beginner level constructor
  3. void main(){
  4. //creating a object called 'jenny'
  5. Human jenny = Human(15);
  6. //now accessing method talk
  7. jenny.talk('hello world');
  8. print('i am ${jenny.height} years old');
  9. }
  10.  
  11. class Human{
  12. //properties
  13. double height;
  14. int age=1;
  15.  
  16. //constructor
  17. Human(double startingHeight){
  18. height = startingHeight;
  19. }
  20.  
  21. //methods
  22. void talk(String speak){
  23. print(speak);
  24. }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement