Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. class Thing {
  2. constructor(isLiving){
  3. this.isLiving = isLiving;
  4. }
  5.  
  6. doSomething() {
  7. console.log('doing some')
  8. }
  9. }
  10.  
  11. class Aerobic extends Thing{
  12. constructor(lungSize) {
  13. super(true)
  14. this.lungSize = lungSize;
  15. }
  16.  
  17. breath() {
  18. return 'Inhale, exale';
  19. }
  20. }
  21.  
  22. const serAerobico = new Aerobic('grande');
  23. // console.dir(serAerobico)
  24.  
  25. class Person extends Aerobic{
  26. constructor(firstName, lastName) {
  27. super('grandao')
  28. this.firstName = firstName;
  29. this.lastName = lastName
  30. }
  31.  
  32. get getNameWithGet() {
  33. return `${this.firstName} ${this.lastName}`
  34. }
  35.  
  36. getName() {
  37. return `${this.firstName} ${this.lastName}`
  38. }
  39.  
  40. introduction() {
  41. return `Hi, my name is ${this.getNameWithGet}`
  42. }
  43. }
  44.  
  45. class Dog extends Aerobic{
  46. constructor(name) {
  47. super('pequeno')
  48. this.name = name;
  49. }
  50.  
  51. introduction() {
  52. return `Woof! WOof!`
  53. }
  54. }
  55.  
  56. const Vinicius = new Person('Vinicius', 'Santana');
  57. const Fernanda = new Person('Fernanda', 'Silva');
  58. const Bro = new Dog('Bro');
  59.  
  60. console.dir(Vinicius)
  61. console.dir(Fernanda)
  62. console.dir(Bro)
  63.  
  64. console.log(Vinicius.breath())
  65.  
  66. console.log(Vinicius.introduction())
  67. console.log(Vinicius.getName())
  68. console.log(Vinicius.getNameWithGet)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement