Guest User

Untitled

a guest
Jan 16th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. class Person{
  2. String firstName;
  3. int age;
  4.  
  5. Person(this.firstName,this.age);
  6.  
  7. printName(){
  8. print(firstName);
  9. }
  10.  
  11. /*setName(name){
  12. this.firstName = name;
  13. }*/
  14.  
  15. /*setAge(age){
  16. this.age = age;
  17. }*/
  18.  
  19. printAge(){
  20. print(age);
  21. }
  22.  
  23. getName(){
  24. return this.firstName;
  25. }
  26. getAge(){
  27. return this.age;
  28. }
  29.  
  30. }
  31.  
  32. void main(){
  33. /*var p1 = new Person();
  34. p1.firstName = 'Harsh';
  35. p1.printName(); */
  36.  
  37. Person p1 = new Person('Harsh',20);
  38. //p1.setName('Harsh');
  39. //p1.setAge(20);
  40. //p1.printName();
  41. String p1Name = p1.getName();
  42. print(p1Name);
  43.  
  44. Person p2 = new Person('Stephen',28);
  45. //p2.setName("Stephen");
  46. //p2.setAge(28);
  47. //p2.printName();
  48. int p2Age = p2.getAge();
  49. print(p2Age);
  50.  
  51. }
Add Comment
Please, Sign In to add comment