From a4f0b5c1fae2b9690f3c86a719646a5d4caf43fc Mon Sep 17 00:00:00 2001 From: ConanGoodwin Date: Thu, 12 Jan 2023 15:05:30 -0300 Subject: [PATCH 1/4] conteudo 001 --- Md03_Dev_Back_end/Bloco26/26.2/conteudo001.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Md03_Dev_Back_end/Bloco26/26.2/conteudo001.ts diff --git a/Md03_Dev_Back_end/Bloco26/26.2/conteudo001.ts b/Md03_Dev_Back_end/Bloco26/26.2/conteudo001.ts new file mode 100644 index 00000000..63a1fd03 --- /dev/null +++ b/Md03_Dev_Back_end/Bloco26/26.2/conteudo001.ts @@ -0,0 +1,36 @@ +class Animal { + constructor(public name: string, private _birthDate: Date) {} + + get age() { + const timeDiff = Math.abs( + Date.now() - + new Date(this._birthDate).getTime() + ); + + return Math.floor(timeDiff / (1000 * 3600 * 24) / 365.25); + } +} + +class Mammal extends Animal { + walk() { + console.log(`${this.name} está andando`); + } +} + +class Bird extends Animal { + fly() { + console.log(`${this.name} está voando!`) + } +} + +const tigger = new Mammal('tigre', new Date(Date.parse('May 03, 2020'))); +const parrot = new Bird('Papagaio', new Date(Date.parse('Jun 07, 2017'))); + +const main = (animal: Animal) => { + console.log(animal.age); +} + +main(tigger); +tigger.walk(); +console.log(parrot.age); +parrot.fly(); \ No newline at end of file From 16e7ff106da12c05be3a5ebe318f7ad1efa9d01f Mon Sep 17 00:00:00 2001 From: ConanGoodwin Date: Thu, 12 Jan 2023 15:48:25 -0300 Subject: [PATCH 2/4] conteudo 002 --- Md03_Dev_Back_end/Bloco26/26.2/conteudo001.ts | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/Md03_Dev_Back_end/Bloco26/26.2/conteudo001.ts b/Md03_Dev_Back_end/Bloco26/26.2/conteudo001.ts index 63a1fd03..a926f95e 100644 --- a/Md03_Dev_Back_end/Bloco26/26.2/conteudo001.ts +++ b/Md03_Dev_Back_end/Bloco26/26.2/conteudo001.ts @@ -33,4 +33,38 @@ const main = (animal: Animal) => { main(tigger); tigger.walk(); console.log(parrot.age); -parrot.fly(); \ No newline at end of file +parrot.fly(); + +class Superclass { + constructor(public isSuper: boolean = true) {} + + protected sayHello() { + console.log('Olá Mundo!'); + } +} + +class Subclass extends Superclass { + constructor() { + super(false); + } + + sayHello2() { + this.sayHello(); + } +} + +function myFunction(objClass: Subclass) { + objClass.sayHello2(); +} + +function mySuperFunction(objClass: Superclass) { + (objClass.isSuper) ? console.log('super') : console.log('sub'); +} + +const objSubClass = new Subclass(); +const objSupreClass = new Superclass(); + +myFunction(objSubClass); +// myFunction(objSupreClass); +mySuperFunction(objSubClass); +mySuperFunction(objSupreClass); \ No newline at end of file From f7f854d53b0e2c2ff4d9bb208155c9bd84b2407d Mon Sep 17 00:00:00 2001 From: ConanGoodwin Date: Thu, 12 Jan 2023 16:14:14 -0300 Subject: [PATCH 3/4] =?UTF-8?q?fixa=C3=A7=C3=A3o=20conteudo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Md03_Dev_Back_end/Bloco26/26.2/conteudoPt2.ts | 29 +++++++++++++++++++ .../Bloco26/26.2/fixarConteudo.ts | 17 +++++++++++ 2 files changed, 46 insertions(+) create mode 100644 Md03_Dev_Back_end/Bloco26/26.2/conteudoPt2.ts create mode 100644 Md03_Dev_Back_end/Bloco26/26.2/fixarConteudo.ts diff --git a/Md03_Dev_Back_end/Bloco26/26.2/conteudoPt2.ts b/Md03_Dev_Back_end/Bloco26/26.2/conteudoPt2.ts new file mode 100644 index 00000000..9571861d --- /dev/null +++ b/Md03_Dev_Back_end/Bloco26/26.2/conteudoPt2.ts @@ -0,0 +1,29 @@ +interface Animal { + name: string; + age: number; + + getBirthDate(): Date; +} + +class Birds implements Animal { + constructor(public name: string, private birthDate: Date) {} + + get age() { + var timeDiff = Math.abs(Date.now() - new Date(this.birthDate).getTime()); + + return Math.floor(timeDiff / (1000 * 3600 * 24) / 365.25); + } + + getBirthDate(): Date { + return this.birthDate; + } + + fly() { + console.log(`${this.name} está voando!`); + } +} + +const parrot02 = new Birds('Papagaio',new Date(Date.parse('Aug 16, 2015'))); + +console.log(parrot02.age); +parrot02.fly(); \ No newline at end of file diff --git a/Md03_Dev_Back_end/Bloco26/26.2/fixarConteudo.ts b/Md03_Dev_Back_end/Bloco26/26.2/fixarConteudo.ts new file mode 100644 index 00000000..c6898c0e --- /dev/null +++ b/Md03_Dev_Back_end/Bloco26/26.2/fixarConteudo.ts @@ -0,0 +1,17 @@ +interface MyInterface { + myNumber: number; + + myFunc(myParam: number): string; +} + +class MyClass implements MyInterface { + constructor(public myNumber: number) {} + + myFunc(num: number) { + return `${num + this.myNumber}`; + } +} + +const numero = new MyClass(3); + +console.log(numero.myFunc(2)); \ No newline at end of file From d4071ca46ed116d62cdc27c5771b81d7f472946c Mon Sep 17 00:00:00 2001 From: ConanGoodwin Date: Thu, 12 Jan 2023 18:06:06 -0300 Subject: [PATCH 4/4] =?UTF-8?q?fixa=C3=A7=C3=A3o=20conteudo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Md03_Dev_Back_end/Bloco26/26.2/conteudoPt2.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Md03_Dev_Back_end/Bloco26/26.2/conteudoPt2.ts b/Md03_Dev_Back_end/Bloco26/26.2/conteudoPt2.ts index 9571861d..2e105fbf 100644 --- a/Md03_Dev_Back_end/Bloco26/26.2/conteudoPt2.ts +++ b/Md03_Dev_Back_end/Bloco26/26.2/conteudoPt2.ts @@ -23,7 +23,7 @@ class Birds implements Animal { } } -const parrot02 = new Birds('Papagaio',new Date(Date.parse('Aug 16, 2015'))); +export const parrot = new Birds('Papagaio',new Date(Date.parse('Aug 16, 2015'))); -console.log(parrot02.age); -parrot02.fly(); \ No newline at end of file +console.log(parrot.age); +parrot.fly(); \ No newline at end of file