SHARE
TWEET

Untitled

a guest Oct 18th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class person
  2. {
  3.     private name: string;
  4.     private age: number;
  5.  
  6.     constructor(name: string, age: number)
  7.     {
  8.         this.name = name;
  9.         this.age = age;
  10.     }
  11.  
  12.     tellMyName(): string
  13.     {
  14.         return `I am ${this.name}`;
  15.     }
  16.  
  17.     tellMyAge(): string
  18.     {
  19.         return `I am ${this.age} years old`;
  20.     }
  21. }
  22.  
  23. const person1 = new person ('John', 40);
  24. const person2 = new person ('Mary', 35);
  25.  
  26. console.log(person1.tellMyName());
  27. console.log(person1.tellMyAge());
  28. console.log(person2.tellMyName());
  29. 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