SHARE
TWEET

Untitled

a guest Oct 18th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Person {
  2.     private name : string;
  3.     private age : number;
  4.  
  5.     constructor(name: string, age: number){
  6.         this.name = name;
  7.         this.age =age;
  8.     }
  9.  
  10.     tellMyName(): string {
  11.         return "I am " + this.name;
  12.     }
  13.     tellMyAge(): string {
  14.         return "I am " + this.age + " years old";
  15.     }
  16. }
  17. const person1 = new Person("John", 40);
  18. const person2 = new Person("Mary", 35);
  19.  
  20. console.log(person1.tellMyName());
  21. console.log(person1.tellMyAge());
  22. console.log(person2.tellMyName());
  23. console.log(person2.tellMyAge());
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top