From 150fd87f78b8282422b24a838adae494eac31322 Mon Sep 17 00:00:00 2001 From: Kyriale Morant-Cavalcanti Date: Fri, 28 Jan 2022 20:55:54 -0300 Subject: [PATCH 1/6] =?UTF-8?q?come=C3=A7ando=20o=20projeto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modulo4/intro-typescript/.gitignore | 105 ++++++++++++++++++++ modulo4/intro-typescript/src/index.ts | 0 modulo4/node-package-json/package-lock.json | 11 +- modulo4/node-package-json/respostas.txt | 6 +- 4 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 modulo4/intro-typescript/.gitignore create mode 100644 modulo4/intro-typescript/src/index.ts diff --git a/modulo4/intro-typescript/.gitignore b/modulo4/intro-typescript/.gitignore new file mode 100644 index 0000000..bee915c --- /dev/null +++ b/modulo4/intro-typescript/.gitignore @@ -0,0 +1,105 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt +dist +build/ + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and *not* Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port diff --git a/modulo4/intro-typescript/src/index.ts b/modulo4/intro-typescript/src/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/modulo4/node-package-json/package-lock.json b/modulo4/node-package-json/package-lock.json index 48e341a..b2c26b0 100644 --- a/modulo4/node-package-json/package-lock.json +++ b/modulo4/node-package-json/package-lock.json @@ -1,3 +1,12 @@ { - "lockfileVersion": 1 + "lockfileVersion": 1, + "name": "aula-node", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "start": "node ./index.js" + }, + "author": "Kyriale Cavalcanti", + "license": "ISC" } diff --git a/modulo4/node-package-json/respostas.txt b/modulo4/node-package-json/respostas.txt index 8d247e6..9a1a143 100644 --- a/modulo4/node-package-json/respostas.txt +++ b/modulo4/node-package-json/respostas.txt @@ -1,3 +1,7 @@ Exercício 1 a) Como fazemos para acessar os parâmetros passados na linha de comando para o Node? -R - Usa-se o argumento como "prosess.argv". Isso salva os dados como uma cópia e "traduz" eles para node. \ No newline at end of file +R - Usa-se o argumento como "prosess.argv". Isso salva os dados como uma cópia e "traduz" eles para node. + +b) Crie um programa que receba seu nome e sua idade. Após receber estes valores, imprima no console uma mensagem que siga a seguinte estrutura: +"Olá, (Nome)! Você tem (sua idade) anos." + From 705cd53404271d8ee924db2ef9a3652665cf1662 Mon Sep 17 00:00:00 2001 From: Kyriale Morant-Cavalcanti Date: Fri, 28 Jan 2022 21:09:08 -0300 Subject: [PATCH 2/6] =?UTF-8?q?exerc=C3=ADcio=2001,=20n=20sei=20pq=20criou?= =?UTF-8?q?=20um=20arquivo=20novo,=20mas=20funcinou,=20rodei=20os=20comand?= =?UTF-8?q?os=20tsc=20index.ts=20.=20e=20node=20index.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modulo4/intro-typescript/package.json | 12 ++++++++++++ modulo4/intro-typescript/src/index.js | 23 +++++++++++++++++++++++ modulo4/intro-typescript/src/index.ts | 23 +++++++++++++++++++++++ modulo4/intro-typescript/tsconfig.json | 11 +++++++++++ 4 files changed, 69 insertions(+) create mode 100644 modulo4/intro-typescript/package.json create mode 100644 modulo4/intro-typescript/src/index.js create mode 100644 modulo4/intro-typescript/tsconfig.json diff --git a/modulo4/intro-typescript/package.json b/modulo4/intro-typescript/package.json new file mode 100644 index 0000000..a9d13c7 --- /dev/null +++ b/modulo4/intro-typescript/package.json @@ -0,0 +1,12 @@ +{ + "name": "intro-typescript", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "start": "tsc && node ./build/index.js" + }, + "keywords": [], + "author": "Kyriale Cavalcanti", + "license": "ISC" +} diff --git a/modulo4/intro-typescript/src/index.js b/modulo4/intro-typescript/src/index.js new file mode 100644 index 0000000..10eee89 --- /dev/null +++ b/modulo4/intro-typescript/src/index.js @@ -0,0 +1,23 @@ +//1) A seguinte função em JavaScript recebe como parâmetro os tamanhos dos três lados do triângulo: ladoA, ladoB, ladoC e retorna se ele é equilátero, isósceles ou escaleno. Refatore a função para o Typescript. +// Código em JavaScript: +// function checaTriangulo(a, b, c) { +// if (a !== b && b !== c) { +// return "Escaleno"; +// } else if (a === b && b === c) { +// return "Equilátero"; +// } else { +// return "Isósceles"; +// } +// } +function checaTriangulo(a, b, c) { + if (a !== b && b !== c) { + return "Escaleno"; + } + else if (a === b && b === c) { + return "Equilátero"; + } + else { + return "Isósceles"; + } +} +console.log(checaTriangulo(1, 2, 2)); diff --git a/modulo4/intro-typescript/src/index.ts b/modulo4/intro-typescript/src/index.ts index e69de29..6ba845f 100644 --- a/modulo4/intro-typescript/src/index.ts +++ b/modulo4/intro-typescript/src/index.ts @@ -0,0 +1,23 @@ +//1) A seguinte função em JavaScript recebe como parâmetro os tamanhos dos três lados do triângulo: ladoA, ladoB, ladoC e retorna se ele é equilátero, isósceles ou escaleno. Refatore a função para o Typescript. +// Código em JavaScript: +// function checaTriangulo(a, b, c) { +// if (a !== b && b !== c) { +// return "Escaleno"; +// } else if (a === b && b === c) { +// return "Equilátero"; +// } else { +// return "Isósceles"; +// } +// } + +function checaTriangulo(a: number, b: number, c: number):string { + if (a !== b && b !== c) { + return "Escaleno"; + } else if (a === b && b === c) { + return "Equilátero"; + } else { + return "Isósceles"; + } +} + +console.log(checaTriangulo(1, 2, 2)) \ No newline at end of file diff --git a/modulo4/intro-typescript/tsconfig.json b/modulo4/intro-typescript/tsconfig.json new file mode 100644 index 0000000..553fee6 --- /dev/null +++ b/modulo4/intro-typescript/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "es6", /* Specify ECMAScript target version */ + "module": "commonjs", /* Specify module code generation */ + "sourceMap": true, /* Generates corresponding '.map' file. */ + "outDir": "./build", /* Redirect output structure to the directory. */ + "rootDir": "./src", /* Specify the root directory of input files. */ + "removeComments": true, /* Do not emit comments to output. */ + "noImplicitAny": true /* Raise error on declarations with an implied 'any' type. */ + } + } \ No newline at end of file From 2293357b8cd68155b1c5a2821495f4cc1e34f632 Mon Sep 17 00:00:00 2001 From: Kyriale Morant-Cavalcanti Date: Sun, 30 Jan 2022 19:32:56 -0300 Subject: [PATCH 3/6] =?UTF-8?q?exerc=C3=ADcio=202,=20est=C3=A1=20dando=20e?= =?UTF-8?q?rro=20de=20digita=C3=A7=C3=A3o=20com=20'=20:=20'=20,=20mas=20n?= =?UTF-8?q?=20entendi=20onde=20estaria=20sobrando=20os=202=20pontos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modulo4/intro-typescript/package-lock.json | 14 ++++++++++++++ modulo4/intro-typescript/package.json | 5 ++++- modulo4/intro-typescript/src/exercicio-2.ts | 18 ++++++++++++++++++ modulo4/intro-typescript/src/exercicio-3.ts | 0 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 modulo4/intro-typescript/package-lock.json create mode 100644 modulo4/intro-typescript/src/exercicio-2.ts create mode 100644 modulo4/intro-typescript/src/exercicio-3.ts diff --git a/modulo4/intro-typescript/package-lock.json b/modulo4/intro-typescript/package-lock.json new file mode 100644 index 0000000..cf605ac --- /dev/null +++ b/modulo4/intro-typescript/package-lock.json @@ -0,0 +1,14 @@ +{ + "name": "intro-typescript", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/node": { + "version": "17.0.13", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.13.tgz", + "integrity": "sha512-Y86MAxASe25hNzlDbsviXl8jQHb0RDvKt4c40ZJQ1Don0AAL0STLZSs4N+6gLEO55pedy7r2cLwS+ZDxPm/2Bw==", + "dev": true + } + } +} diff --git a/modulo4/intro-typescript/package.json b/modulo4/intro-typescript/package.json index a9d13c7..f368cbc 100644 --- a/modulo4/intro-typescript/package.json +++ b/modulo4/intro-typescript/package.json @@ -8,5 +8,8 @@ }, "keywords": [], "author": "Kyriale Cavalcanti", - "license": "ISC" + "license": "ISC", + "devDependencies": { + "@types/node": "^17.0.13" + } } diff --git a/modulo4/intro-typescript/src/exercicio-2.ts b/modulo4/intro-typescript/src/exercicio-2.ts new file mode 100644 index 0000000..741e1fd --- /dev/null +++ b/modulo4/intro-typescript/src/exercicio-2.ts @@ -0,0 +1,18 @@ +// 2) A seguinte função em JavaScript pergunta ao usuário suas três cores favoritas e imprime no console um array que contenha essas três cores. Refatore a função para o Typescript. + +// function imprimeTresCoresFavoritas() { +// const cor1 = prompt("Insira sua primeira cor favorita") +// const cor2 = prompt("Insira sua segunda cor favorita") +// const cor3 = prompt("Insira sua terceira cor favorita") +// console.log([cor1, cor2, cor3]) +// } + +function imprimeTresCoresFavoritas():void { + let cor1:string = process.argv[2] + let cor2:string = process.argv[3] + let cor3:string = process.argv[4] + + console.log([cor1, cor2, cor3]) +} + +imprimeTresCoresFavoritas() \ No newline at end of file diff --git a/modulo4/intro-typescript/src/exercicio-3.ts b/modulo4/intro-typescript/src/exercicio-3.ts new file mode 100644 index 0000000..e69de29 From 74aad7c950ce07d1dc44603caf9698bdaa8f4fea Mon Sep 17 00:00:00 2001 From: Kyriale Morant-Cavalcanti Date: Sun, 30 Jan 2022 19:42:54 -0300 Subject: [PATCH 4/6] =?UTF-8?q?exerc=C3=ADcio=203=20com=20o=20msm=20erro?= =?UTF-8?q?=20do=20exerc=C3=ADcio=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modulo4/intro-typescript/src/exercicio-3.ts | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/modulo4/intro-typescript/src/exercicio-3.ts b/modulo4/intro-typescript/src/exercicio-3.ts index e69de29..6084c70 100644 --- a/modulo4/intro-typescript/src/exercicio-3.ts +++ b/modulo4/intro-typescript/src/exercicio-3.ts @@ -0,0 +1,23 @@ +/* +3) A função recebe um ano e retorna um booleano (true ou false) que indica se o ano é bissexto. Um ano é bissexto de acordo com as seguintes condições: + + - **São bissextos** todos os anos múltiplos de 400**.** + - **São bissextos** todos os múltiplos de 4, exceto se for múltiplo de 100 mas não de 400**.** + - **Não são bissextos** todos os demais anos. + + Com isso em mente, refatore a função para o Typescript. + +function checaAnoBissexto(ano) { + const cond1 = ano % 400 === 0 + const cond2 = (ano % 4 === 0) && (ano % 100 !== 0) + return cond1 || cond2 +} +*/ + +function checaAnoBissexto(ano:number):boolean { + let cond1:boolean = ano % 400 === 0 + let cond2:boolean = (ano % 4 === 0) && (ano % 100 !== 0) + return cond1 || cond2 +} + +console.log(checaAnoBissexto(400)) \ No newline at end of file From c916dc9e1ce9bb0be7042067fffa069dddd897d7 Mon Sep 17 00:00:00 2001 From: Kyriale Morant-Cavalcanti Date: Sun, 30 Jan 2022 19:55:19 -0300 Subject: [PATCH 5/6] =?UTF-8?q?exerc=C3=ADcio=204=20com=20o=20msm=20erro?= =?UTF-8?q?=20do=20exerc=C3=ADcio=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modulo4/intro-typescript/src/exercicio-4.ts | 39 +++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 modulo4/intro-typescript/src/exercicio-4.ts diff --git a/modulo4/intro-typescript/src/exercicio-4.ts b/modulo4/intro-typescript/src/exercicio-4.ts new file mode 100644 index 0000000..e190175 --- /dev/null +++ b/modulo4/intro-typescript/src/exercicio-4.ts @@ -0,0 +1,39 @@ +/* +4) A seguinte função recebe dois números como parâmetro e retorna a diferença entre o maior número e o menor. Dessa forma, refatore a função para o Typescript. + +function comparaDoisNumeros(num1, num2) { + let maiorNumero; + let menorNumero; + + if (num1 > num2) { + maiorNumero = num1; + menorNumero = num2; + } else { + maiorNumero = num2; + menorNumero = num1; + } + + const diferenca = maiorNumero - menorNumero; + + return diferenca +} + +*/ + +function comparaDoisNumeros(num1:number, num2:number): number { + let maiorNumero + let menorNumero + + if (num1 > num2) { + maiorNumero = num1; + menorNumero = num2; + } else { + maiorNumero = num2; + menorNumero = num1; + + const diferenca = maiorNumero - menorNumero; + + return diferenca +} +} +console.log(comparaDoisNumeros(10, 30)) \ No newline at end of file From 1207e1d4d09441aa44f69388f459aba009860c7a Mon Sep 17 00:00:00 2001 From: Kyriale Morant-Cavalcanti Date: Tue, 1 Feb 2022 23:52:22 -0300 Subject: [PATCH 6/6] =?UTF-8?q?exerc=C3=ADcio=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modulo4/intro-typescript/package-lock.json | 429 ++++++++++++++++++++ modulo4/intro-typescript/package.json | 7 +- modulo4/intro-typescript/src/exercicio-2.ts | 4 +- modulo4/intro-typescript/src/exercicio-3.js | 21 + modulo4/intro-typescript/src/exercicio-5.ts | 41 ++ modulo4/intro-typescript/src/index.ts | 14 +- 6 files changed, 511 insertions(+), 5 deletions(-) create mode 100644 modulo4/intro-typescript/src/exercicio-3.js create mode 100644 modulo4/intro-typescript/src/exercicio-5.ts diff --git a/modulo4/intro-typescript/package-lock.json b/modulo4/intro-typescript/package-lock.json index cf605ac..047883f 100644 --- a/modulo4/intro-typescript/package-lock.json +++ b/modulo4/intro-typescript/package-lock.json @@ -9,6 +9,435 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.13.tgz", "integrity": "sha512-Y86MAxASe25hNzlDbsviXl8jQHb0RDvKt4c40ZJQ1Don0AAL0STLZSs4N+6gLEO55pedy7r2cLwS+ZDxPm/2Bw==", "dev": true + }, + "@types/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-FKjsOVbC6B7bdSB5CuzyHCkK69I=", + "dev": true + }, + "@types/strip-json-comments": { + "version": "0.0.30", + "resolved": "https://registry.npmjs.org/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz", + "integrity": "sha512-7NQmHra/JILCd1QqpSzl8+mJRc8ZHz3uDm8YV1Ks9IhK0epEiTw8aIErbvH9PI+6XbqhyIQy3462nEsn7UVzjQ==", + "dev": true + }, + "anymatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", + "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "dev": true, + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, + "chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "dev": true, + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true + }, + "dynamic-dedupe": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/dynamic-dedupe/-/dynamic-dedupe-0.3.0.tgz", + "integrity": "sha1-BuRMIj9eTpTXjvnbI6ZRXOL5YqE=", + "dev": true, + "requires": { + "xtend": "^4.0.0" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "optional": true + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-core-module": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz", + "integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "requires": { + "picomatch": "^2.2.1" + } + }, + "resolve": { + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", + "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", + "dev": true, + "requires": { + "is-core-module": "^2.8.1", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + } + }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + }, + "tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true + }, + "ts-node": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-9.1.1.tgz", + "integrity": "sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg==", + "dev": true, + "requires": { + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "source-map-support": "^0.5.17", + "yn": "3.1.1" + } + }, + "ts-node-dev": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/ts-node-dev/-/ts-node-dev-1.1.8.tgz", + "integrity": "sha512-Q/m3vEwzYwLZKmV6/0VlFxcZzVV/xcgOt+Tx/VjaaRHyiBcFlV0541yrT09QjzzCxlDZ34OzKjrFAynlmtflEg==", + "dev": true, + "requires": { + "chokidar": "^3.5.1", + "dynamic-dedupe": "^0.3.0", + "minimist": "^1.2.5", + "mkdirp": "^1.0.4", + "resolve": "^1.0.0", + "rimraf": "^2.6.1", + "source-map-support": "^0.5.12", + "tree-kill": "^1.2.2", + "ts-node": "^9.0.0", + "tsconfig": "^7.0.0" + } + }, + "tsconfig": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-7.0.0.tgz", + "integrity": "sha512-vZXmzPrL+EmC4T/4rVlT2jNVMWCi/O4DIiSj3UHg1OE5kCKbk4mfrXc6dZksLgRM/TZlKnousKH9bbTazUWRRw==", + "dev": true, + "requires": { + "@types/strip-bom": "^3.0.0", + "@types/strip-json-comments": "0.0.30", + "strip-bom": "^3.0.0", + "strip-json-comments": "^2.0.0" + } + }, + "typescript": { + "version": "4.5.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", + "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "dev": true + }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true } } } diff --git a/modulo4/intro-typescript/package.json b/modulo4/intro-typescript/package.json index f368cbc..860e9e0 100644 --- a/modulo4/intro-typescript/package.json +++ b/modulo4/intro-typescript/package.json @@ -4,12 +4,15 @@ "description": "", "main": "index.js", "scripts": { - "start": "tsc && node ./build/index.js" + "start": "tsc && node ./build/index.js", + "dev": "ts-node-dev ./src/index.ts" }, "keywords": [], "author": "Kyriale Cavalcanti", "license": "ISC", "devDependencies": { - "@types/node": "^17.0.13" + "@types/node": "^17.0.13", + "ts-node-dev": "^1.1.8", + "typescript": "^4.5.5" } } diff --git a/modulo4/intro-typescript/src/exercicio-2.ts b/modulo4/intro-typescript/src/exercicio-2.ts index 741e1fd..308c0e0 100644 --- a/modulo4/intro-typescript/src/exercicio-2.ts +++ b/modulo4/intro-typescript/src/exercicio-2.ts @@ -7,7 +7,7 @@ // console.log([cor1, cor2, cor3]) // } -function imprimeTresCoresFavoritas():void { +function imprimeTresCoresFavoritas2():void { let cor1:string = process.argv[2] let cor2:string = process.argv[3] let cor3:string = process.argv[4] @@ -15,4 +15,4 @@ function imprimeTresCoresFavoritas():void { console.log([cor1, cor2, cor3]) } -imprimeTresCoresFavoritas() \ No newline at end of file +imprimeTresCoresFavoritas2() \ No newline at end of file diff --git a/modulo4/intro-typescript/src/exercicio-3.js b/modulo4/intro-typescript/src/exercicio-3.js new file mode 100644 index 0000000..24cc283 --- /dev/null +++ b/modulo4/intro-typescript/src/exercicio-3.js @@ -0,0 +1,21 @@ +/* +3) A função recebe um ano e retorna um booleano (true ou false) que indica se o ano é bissexto. Um ano é bissexto de acordo com as seguintes condições: + + - **São bissextos** todos os anos múltiplos de 400**.** + - **São bissextos** todos os múltiplos de 4, exceto se for múltiplo de 100 mas não de 400**.** + - **Não são bissextos** todos os demais anos. + + Com isso em mente, refatore a função para o Typescript. + +function checaAnoBissexto(ano) { + const cond1 = ano % 400 === 0 + const cond2 = (ano % 4 === 0) && (ano % 100 !== 0) + return cond1 || cond2 +} +*/ +function checaAnoBissexto(ano) { + var cond1 = ano % 400 === 0; + var cond2 = (ano % 4 === 0) && (ano % 100 !== 0); + return cond1 || cond2; +} +console.log(checaAnoBissexto(400)); diff --git a/modulo4/intro-typescript/src/exercicio-5.ts b/modulo4/intro-typescript/src/exercicio-5.ts new file mode 100644 index 0000000..492d776 --- /dev/null +++ b/modulo4/intro-typescript/src/exercicio-5.ts @@ -0,0 +1,41 @@ +/* +5) A função abaixo pergunta ao usuário o ano atual, o ano de nascimento de uma pessoa, e o ano em que sua carteira de identidade foi emitida (nessa ordem). A função retorna um booleano que indica se a carteira precisa ser renovada ou não. A carteira precisa ser renovada segundo os seguintes critérios: + +- Para pessoas com menos de 20 anos, ou exatamente 20 anos, deve ser renovada de 5 em 5 anos (se for exatamente 5 anos, deve ser renovada). +- Para pessoas entre 20 e 50 anos, ou exatamente 50, deve ser renovada de 10 em 10 anos (se for exatamente 10 anos, deve ser renovada). +- Para pessoas acima dos 50 anos, deve ser renovada de 15 em 15 anos + +Dito isso, refatore a função para o Typescript + +function checaRenovacaoRG() { + const anoAtual = Number(prompt("Digite o ano atual")) + const anoNascimento = Number(prompt("Digite o ano de nascimento")) + const anoEmissao = Number(prompt("Digite o ano de emissão do documento")) + + const idade = anoAtual - anoNascimento + const tempoCarteira = anoAtual - anoEmissao + + const cond1 = idade <= 20 && tempoCarteira >= 5 + const cond2 = idade > 20 && idade <= 50 && tempoCarteira >= 10 + const cond3 = idade > 50 && tempoCarteira >= 15 + + return (cond1 || cond2 || cond3) +} +*/ + +function checaRenovacaoRG() : boolean { + let anoAtual = Number(process.argv[2]) + let anoNascimento = Number(process.argv[3]) + let anoEmissao = Number(process.argv[4]) + + let idade = anoAtual - anoNascimento + let tempoCarteira = anoAtual - anoEmissao + + const cond1 = idade <= 20 && tempoCarteira >= 5 + const cond2 = idade > 20 && idade <= 50 && tempoCarteira >= 10 + const cond3 = idade > 50 && tempoCarteira >= 15 + + return (cond1 || cond2 || cond3) +} + +console.log(checaRenovacaoRG()) \ No newline at end of file diff --git a/modulo4/intro-typescript/src/index.ts b/modulo4/intro-typescript/src/index.ts index 6ba845f..bc8bb27 100644 --- a/modulo4/intro-typescript/src/index.ts +++ b/modulo4/intro-typescript/src/index.ts @@ -20,4 +20,16 @@ function checaTriangulo(a: number, b: number, c: number):string { } } -console.log(checaTriangulo(1, 2, 2)) \ No newline at end of file +console.log(checaTriangulo(1, 2, 2)) + +//2) + +function imprimeTresCoresFavoritas():void { + let cor1:string = process.argv[2] + let cor2:string = process.argv[3] + let cor3:string = process.argv[4] + + console.log([cor1, cor2, cor3]) +} + +imprimeTresCoresFavoritas() \ No newline at end of file