- Composição
-
Todos os povos da terra média, devem ter uma lista de equipamentos
- Equipamentos tem: nome e preço
- Uma pessoa da terra média começa sempre com:
- Adaga Enferrujada
- Custa 5 dinheiros
-
Implementação sem composição
import People from "./People";
-
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "strictPropertyInitialization": false, | |
class Person { | |
name: string | |
} | |
const person = new Person(); | |
// erro no runtime: cannot read properties of undefined, reading "length" | |
person.name.length |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// undefined = nenhum parâmetro é necessário, enquanto que: | |
// z.object({ | |
// id: z.string({ | |
// invalid_type_error: 'INVALID_ID_TYPE', | |
// required_error: 'REQUIRED_ID', | |
// }), | |
//}) representa uma rota que espera os parâmetros no seguinte formato: { id: string } | |
const appRoutes = { | |
home: undefined, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// no mongo ou mongosh | |
// use aula_11_4; | |
// no vscode \/ | |
use("aula_11_4"); | |
db.students.drop() | |
db.students.insertMany( | |
[ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Turma { | |
constructor(private inspiracao = 100){} | |
incrementInspiracao(valor: number){ | |
this.inspiracao += valor | |
} | |
getInspiracao(){ | |
return this.inspiracao | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {describe, expect, it} from 'vitest'; | |
describe('Character', () => { | |
it('should have strength, dexterity and intelligence', () => { | |
const isaac = new Character(5, 6, 7); | |
expect(isaac.strength).toBe(5); | |
expect(isaac.dexterity).toBe(6); | |
expect(isaac.intelligence).toBe(7); | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Encontre o ator Johnny Cage | |
SELECT * FROM sakila.actor | |
WHERE first_name = 'JOHNNY' AND last_name = 'CAGE'; | |
-- Encontre os filmes que podem ser alugados exatamente por 6 dias | |
SELECT * FROM sakila.film WHERE rental_duration = 6 | |
-- Encontre os filmes de classificação R que podem ser alugados exatamente por 6 dias | |
SELECT * FROM sakila.film WHERE rental_duration = 6 AND rating = 'R' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Cadastrar uma nova loja | |
-- Necessário criar um endereço | |
-- Endereço: Rua dos Alfeneiros, Little Whinging | |
-- INSERT INTO sakila.address (district, address, city_id, phone, location) | |
-- VALUES ( | |
-- 'Little Whinging', | |
-- 'Rua dos Alfeneiros', | |
-- 26, | |
-- '12345678901234567890', | |
-- POINT(-48.9494566, -16.3333469) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- DB PIXAR | |
DROP SCHEMA IF EXISTS Pixar; | |
CREATE SCHEMA Pixar; | |
USE Pixar; | |
CREATE TABLE Movies ( | |
id INTEGER auto_increment PRIMARY KEY NOT NULL, | |
title VARCHAR(30) NOT NULL, | |
director VARCHAR(30) NULL, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- SELECT * FROM sakila.address; | |
-- Ver os endereços com nomes das cidades | |
-- SELECT a.address_id, a.address, c.city FROM sakila.address AS a | |
-- INNER JOIN sakila.city AS c | |
-- ON a.city_id = c.city_id | |
-- WHERE a.address_id = 8 | |
-- Ver qual cidade tem mais endereços | |
-- SELECT COUNT(*), sakila.address.city_id, sakila.city.city FROM sakila.address |