From d7f0dd3ef453b44835636435a6ec5699c51fce89 Mon Sep 17 00:00:00 2001 From: Everton <22everton.oliveira@gmail.com> Date: Thu, 17 Jul 2025 10:41:04 -0300 Subject: [PATCH 1/2] Add files via upload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Meu projeto em nodeJS do SuperMarioKart, com as modificações propostas pelo professor. --- 03-projeto-mario-kart/package.json | 6 +- 03-projeto-mario-kart/readme.md | 206 ++++++++-------- 03-projeto-mario-kart/src/index.js | 369 +++++++++++++++-------------- 3 files changed, 301 insertions(+), 280 deletions(-) diff --git a/03-projeto-mario-kart/package.json b/03-projeto-mario-kart/package.json index d1f5e62..0337d68 100644 --- a/03-projeto-mario-kart/package.json +++ b/03-projeto-mario-kart/package.json @@ -1,12 +1,12 @@ { - "name": "aula", + "name": "projeto-corrida-super-mario", "version": "1.0.0", - "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", - "license": "ISC" + "license": "ISC", + "description": "" } diff --git a/03-projeto-mario-kart/readme.md b/03-projeto-mario-kart/readme.md index fd63bb9..afa9294 100644 --- a/03-projeto-mario-kart/readme.md +++ b/03-projeto-mario-kart/readme.md @@ -1,103 +1,103 @@ -

Desafio de projeto do Felipão: Mario Kart.JS

- - - - - - -
- Mario Kart - - Objetivo: -

Mario Kart é uma série de jogos de corrida desenvolvida e publicada pela Nintendo. Nosso desafio será criar uma lógica de um jogo de vídeo game para simular corridas de Mario Kart, levando em consideração as regras e mecânicas abaixo.

-
- -

Players

- - - - - - - - - - - - - - - - - -
-

Mario

- Mario Kart -
-

Velocidade: 4

-

Manobrabilidade: 3

-

Poder: 3

-
-

Peach

- Mario Kart -
-

Velocidade: 3

-

Manobrabilidade: 4

-

Poder: 2

-
-

Yoshi

- Mario Kart -
-

Velocidade: 2

-

Manobrabilidade: 4

-

Poder: 3

-
-

Bowser

- Mario Kart -
-

Velocidade: 5

-

Manobrabilidade: 2

-

Poder: 5

-
-

Luigi

- Mario Kart -
-

Velocidade: 3

-

Manobrabilidade: 4

-

Poder: 4

-
-

Donkey Kong

- Mario Kart -
-

Velocidade: 2

-

Manobrabilidade: 2

-

Poder: 5

-
- -

- -

🕹️ Regras & mecânicas:

- -Jogadores: - - - - -Pistas: - - - -Condição de vitória: - - - +

Desafio de projeto do Felipão: Mario Kart.JS

+ + + + + + +
+ Mario Kart + + Objetivo: +

Mario Kart é uma série de jogos de corrida desenvolvida e publicada pela Nintendo. Nosso desafio será criar uma lógica de um jogo de vídeo game para simular corridas de Mario Kart, levando em consideração as regras e mecânicas abaixo.

+
+ +

Players

+ + + + + + + + + + + + + + + + + +
+

Mario

+ Mario Kart +
+

Velocidade: 4

+

Manobrabilidade: 3

+

Poder: 3

+
+

Peach

+ Mario Kart +
+

Velocidade: 3

+

Manobrabilidade: 4

+

Poder: 2

+
+

Yoshi

+ Mario Kart +
+

Velocidade: 2

+

Manobrabilidade: 4

+

Poder: 3

+
+

Bowser

+ Mario Kart +
+

Velocidade: 5

+

Manobrabilidade: 2

+

Poder: 5

+
+

Luigi

+ Mario Kart +
+

Velocidade: 3

+

Manobrabilidade: 4

+

Poder: 4

+
+

Donkey Kong

+ Mario Kart +
+

Velocidade: 2

+

Manobrabilidade: 2

+

Poder: 5

+
+ +

+ +

🕹️ Regras & mecânicas:

+ +Jogadores: + + + + +Pistas: + + + +Condição de vitória: + + + diff --git a/03-projeto-mario-kart/src/index.js b/03-projeto-mario-kart/src/index.js index e47c78a..f856196 100644 --- a/03-projeto-mario-kart/src/index.js +++ b/03-projeto-mario-kart/src/index.js @@ -1,174 +1,195 @@ -const player1 = { - NOME: "Mario", - VELOCIDADE: 4, - MANOBRABILIDADE: 3, - PODER: 3, - PONTOS: 0, -}; - -const player2 = { - NOME: "Luigi", - VELOCIDADE: 3, - MANOBRABILIDADE: 4, - PODER: 4, - PONTOS: 0, -}; - -async function rollDice() { - return Math.floor(Math.random() * 6) + 1; -} - -async function getRandomBlock() { - let random = Math.random(); - let result; - - switch (true) { - case random < 0.33: - result = "RETA"; - break; - case random < 0.66: - result = "CURVA"; - break; - default: - result = "CONFRONTO"; - } - - return result; -} - -async function logRollResult(characterName, block, diceResult, attribute) { - console.log( - `${characterName} 🎲 rolou um dado de ${block} ${diceResult} + ${attribute} = ${ - diceResult + attribute - }` - ); -} - -async function playRaceEngine(character1, character2) { - for (let round = 1; round <= 5; round++) { - console.log(`🏁 Rodada ${round}`); - - // sortear bloco - let block = await getRandomBlock(); - console.log(`Bloco: ${block}`); - - // rolar os dados - let diceResult1 = await rollDice(); - let diceResult2 = await rollDice(); - - //teste de habilidade - let totalTestSkill1 = 0; - let totalTestSkill2 = 0; - - if (block === "RETA") { - totalTestSkill1 = diceResult1 + character1.VELOCIDADE; - totalTestSkill2 = diceResult2 + character2.VELOCIDADE; - - await logRollResult( - character1.NOME, - "velocidade", - diceResult1, - character1.VELOCIDADE - ); - - await logRollResult( - character2.NOME, - "velocidade", - diceResult2, - character2.VELOCIDADE - ); - } - - if (block === "CURVA") { - totalTestSkill1 = diceResult1 + character1.MANOBRABILIDADE; - totalTestSkill2 = diceResult2 + character2.MANOBRABILIDADE; - - await logRollResult( - character1.NOME, - "manobrabilidade", - diceResult1, - character1.MANOBRABILIDADE - ); - - await logRollResult( - character2.NOME, - "manobrabilidade", - diceResult2, - character2.MANOBRABILIDADE - ); - } - - if (block === "CONFRONTO") { - let powerResult1 = diceResult1 + character1.PODER; - let powerResult2 = diceResult2 + character2.PODER; - - console.log(`${character1.NOME} confrontou com ${character2.NOME}! 🥊`); - - await logRollResult( - character1.NOME, - "poder", - diceResult1, - character1.PODER - ); - - await logRollResult( - character2.NOME, - "poder", - diceResult2, - character2.PODER - ); - - if (powerResult1 > powerResult2 && character2.PONTOS > 0) { - console.log( - `${character1.NOME} venceu o confronto! ${character2.NOME} perdeu 1 ponto 🐢` - ); - character2.PONTOS--; - } - - if (powerResult2 > powerResult1 && character1.PONTOS > 0) { - console.log( - `${character2.NOME} venceu o confronto! ${character1.NOME} perdeu 1 ponto 🐢` - ); - character1.PONTOS--; - } - - console.log( - powerResult2 === powerResult1 - ? "Confronto empatado! Nenhum ponto foi perdido" - : "" - ); - } - - // verificando o vencedor - if (totalTestSkill1 > totalTestSkill2) { - console.log(`${character1.NOME} marcou um ponto!`); - character1.PONTOS++; - } else if (totalTestSkill2 > totalTestSkill1) { - console.log(`${character2.NOME} marcou um ponto!`); - character2.PONTOS++; - } - - console.log("-----------------------------"); - } -} - -async function declareWinner(character1, character2) { - console.log("Resultado final:"); - console.log(`${character1.NOME}: ${character1.PONTOS} ponto(s)`); - console.log(`${character2.NOME}: ${character2.PONTOS} ponto(s)`); - - if (character1.PONTOS > character2.PONTOS) - console.log(`\n${character1.NOME} venceu a corrida! Parabéns! 🏆`); - else if (character2.PONTOS > character1.PONTOS) - console.log(`\n${character2.NOME} venceu a corrida! Parabéns! 🏆`); - else console.log("A corrida terminou em empate"); -} - -(async function main() { - console.log( - `🏁🚨 Corrida entre ${player1.NOME} e ${player2.NOME} começando...\n` - ); - - await playRaceEngine(player1, player2); - await declareWinner(player1, player2); -})(); +const player1 = { + NOME: "Mario", + VELOCIDADE: 4, + MANOBRABILIDADE: 3, + PODER: 3, + PONTOS: 0, +}; + +const player2 = { + NOME: "Luigi", + VELOCIDADE: 3, + MANOBRABILIDADE: 4, + PODER: 4, + PONTOS: 0, +}; + +async function rollDice() { + return Math.floor(Math.random() * 6) + 1; +} + +async function getRandomBlock() { + let random = Math.random(); + let result; + + switch (true) { + case random < 0.33: + result = "RETA"; + break; + case random < 0.66: + result = "CURVA" + break; + default: + result = "CONFRONTO" + break; + } + return result +} + +async function getRandomPower() { + let random = Math.random(); + let result; + + if(random > 0.50){ + result = "CASCO"; + }else + result = "BOMBA"; + return result +} + +async function getRandomTurbo() { + let randomTurbo = Math.random() + let result + + if(randomTurbo > 0.50){ + result = 1 + }else + result = 0 + return result +} + +async function logRollResult(characterName,block,diceResult,attribute) { + console.log(`${characterName} 🎲 rolou o dado de ${block} ${diceResult} + ${attribute} = ${diceResult + attribute}`) + +} + +async function declareWinner(player1,player2){ + console.log("Resultado final:"); + console.log(`${player1.NOME}: ${player1.PONTOS} ponto(s).`); + console.log(`${player2.NOME}: ${player2.PONTOS} ponto(s).`); + + if(player1.PONTOS > player2.PONTOS){ + console.log(`\n${player1.NOME} venceu a corrida! Parabéns! 🏆 `); + }else if(player2.PONTOS > player1.PONTOS){ + console.log(`\n${player2.NOME} venceu a corrida! Parabéns! 🏆 `); + }else{ + console.log("A corrida terminou em empate!") + } +} + +async function playRaceEngine(character1, character2) { + for (let round = 1; round <= 5; round++) { + console.log(`🏁 Rodada ${round}`); + + //sortear bloco + let block = await getRandomBlock() + console.log(`Bloco: ${block}`) + + //rolar os dados + let diceResult1 = await rollDice(); + let diceResult2 = await rollDice(); + + //teste de habilidade + let totalTestSkill1 = 0; + let totalTestSkill2 = 0; + + if(block === "RETA"){ + totalTestSkill1 = diceResult1 + player1.VELOCIDADE; + totalTestSkill2 = diceResult2 + player2.VELOCIDADE; + + await logRollResult(player1.NOME,"velocidade",diceResult1,character1.VELOCIDADE) + await logRollResult(player2.NOME,"velocidade",diceResult2,character2.VELOCIDADE) + } + + if(block === "CURVA"){ + totalTestSkill1 = diceResult1 + player1.MANOBRABILIDADE; + totalTestSkill2 = diceResult2 + player2.MANOBRABILIDADE; + + await logRollResult(player1.NOME,"manobrabilidade",diceResult1,character1.MANOBRABILIDADE) + await logRollResult(player2.NOME,"manobrabilidade",diceResult2,character2.MANOBRABILIDADE) + } + + if(block === "CONFRONTO"){ + let randomTurbo = await getRandomTurbo() + let randomPower = await getRandomPower() + let powerResult1 = diceResult1 + player1.PODER; + let powerResult2 = diceResult2 + player2.PODER; + + console.log(`${player1.NOME} confrontou com ${player2.NOME}!! 🥊🥊`) + + await logRollResult(player1.NOME,"CONFRONTO",diceResult1,player1.PODER); + + await logRollResult(player2.NOME,"CONFRONTO",diceResult2,player2.PODER); + + if(randomPower === "CASCO"){ + if(powerResult1 > powerResult2 && player2.PONTOS > 0){ + console.log(`${player1.NOME} ganhou o confronto utilizando um CASCO! ${player2.NOME} perdeu 1 ponto 🐢`); + if(randomTurbo == 1){ + console.log(`${player1.NOME} Conseguiu um TURBO e ganhou 1 ponto.`) + player1.PONTOS++; + player2.PONTOS--; + }else{ + player2.PONTOS--; + } + } + + if(powerResult2 > powerResult1 && player1.PONTOS > 0){ + console.log(`${player2.NOME} ganhou o confronto utilizando um CASCO! ${player1.NOME} perdeu 1 ponto 🐢`); + if (randomTurbo == 1){ + console.log(`${player2.NOME} Conseguiu um TURBO e ganhou 1 ponto.`) + player2.PONTOS++; + player1.PONTOS--; + }else{ + player1.PONTOS--; + } + + } + } + + if(randomPower === "BOMBA"){ + if(powerResult1 > powerResult2 && player2.PONTOS > 0){ + console.log(`${player1.NOME} ganhou o confronto utilizando uma BOMBA! ${player2.NOME} perdeu 2 pontos 💣`); + if(randomTurbo == 1){ + console.log(`${player1.NOME} Conseguiu um TURBO e ganhou 1 ponto.`) + player1.PONTOS ++; + player2.PONTOS -= 2; + }else{ + player2.PONTOS -= 2; + } + } + + if(powerResult2 > powerResult1 && player1.PONTOS > 0){ + console.log(`${player2.NOME} ganhou o confronto utilizando um BOMBA! ${player1.NOME} perdeu 2 pontos 💣`); + if(randomTurbo == 1){ + console.log(`${player2.NOME} Conseguiu um TURBO e ganhou 1 ponto.`) + player2.PONTOS++; + player1.PONTOS -= 2; + }else{ + player1.PONTOS -= 2; + } + } + } + console.log(powerResult1 === powerResult2 ? 'Confronto empatado! Nenhum ponto foi perdido!' : " "); + } + + //verificando o vencedor + if(totalTestSkill1 > totalTestSkill2){ + console.log(`${player1.NOME} marcou 1 ponto!`) + player1.PONTOS++; + } + else if(totalTestSkill2 > totalTestSkill1){ + console.log(`${player2.NOME} marcou 1 ponto!`) + player2.PONTOS++; + } + + console.log("________________________________________________") +}} + + +(async function main() { + console.log(`🏁🚨 Corrida entre ${player1.NOME} e ${player2.NOME} começando ...\n`); + + await playRaceEngine(player1, player2); + await declareWinner(player1,player2) +})(); + From dcc6a3cbfacee676af64ad4c07a3f51982438a79 Mon Sep 17 00:00:00 2001 From: Everton <22everton.oliveira@gmail.com> Date: Fri, 25 Jul 2025 12:27:09 -0300 Subject: [PATCH 2/2] =?UTF-8?q?Desafio=20de=20c=C3=B3digo=20Shopee=20Cart?= =?UTF-8?q?=20em=20Node.JS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Desafio de código feito de acordo com as orientações do professor, desafio feito com o intuito de aprender a modularizar e organizar melhor os códigos em Node.JS. Adicionado uma feature extra de remover todos os itens do carrinho. --- 06-shopee-cart/package.json | 6 +- 06-shopee-cart/readme.md | 110 ++---------------------- 06-shopee-cart/src/index.js | 60 +++++++------ 06-shopee-cart/src/services/cart.js | 126 ++++++++++++++-------------- 06-shopee-cart/src/services/item.js | 26 +++--- 5 files changed, 124 insertions(+), 204 deletions(-) diff --git a/06-shopee-cart/package.json b/06-shopee-cart/package.json index 3bea32f..581d411 100644 --- a/06-shopee-cart/package.json +++ b/06-shopee-cart/package.json @@ -1,13 +1,13 @@ { "name": "06-shopee-cart", "version": "1.0.0", - "description": "", - "type": "module", "main": "index.js", + "type": "module", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", - "license": "ISC" + "license": "ISC", + "description": "" } diff --git a/06-shopee-cart/readme.md b/06-shopee-cart/readme.md index b32a71e..ec66d74 100644 --- a/06-shopee-cart/readme.md +++ b/06-shopee-cart/readme.md @@ -1,101 +1,9 @@ - -
-

- DIO Education -

Recriando a lógica do carrinho de compras da Shopee

-

-
- - -

- DIO Project - Nivel - -

- - - - - - - - - -
-

Felipe Aguiar

- - @felipeAguiarCode
-
-
-

🎉 10y+ em sistemas comerciais com .NET C# e NODE.JS. -
- 🌟 Desenvolvedor fullstack - Coordenador de educação na DIO -
- 👨‍💻 Foco em front-ends SPA com React, Angular e Vue.js -

- - Material de Apoio - - - Instagram - -
- - -
-
- -## 💻 Descrição Do Projeto - -Vamos criar a lógica por trás do carrinho de compras da shopee, aonde o carrinho armazene itens e faça o cálculo total e de sub-itens automaticamente. - -## 📚 Pré-requisitos de Habilidades e Níveis de Conhecimento - -Antes de ingressar neste conteúdo, é necessário possuir conhecimento prévio nas seguintes áreas: - -- [habilidades ou conhecimentos prévios necessários] - - - Javascript | Intermediário - - Node | Básico - - Modularização | Básica - -- [Outros pré-requisitos] - - - Lógica de Programação | Intermediário - -## 🛠️ Habilidades e Sub-habilidades que vamos aprender neste conteúdo - -- Modularização | Intermediária - -## 🎯 Objetivos e Resultados Esperados - -Após a conclusão do curso/projeto, os estudantes estarão aptos a: - -- Modularizar projetos com maior propriedade -- Como organizar pensamento lógico e funcional -- Base para organizar projetos - - - -
-
- -

- - banner - -

+## Obejetivo + +//Criar um carrinho de compras baseado no carrinho de compras da Shopee, aonde o carrinho armazene itens e faça o calculo de sub-itens automaticamente. + +//dominio da aplicação: Carrinho de compras + +//as entidades representadas +//-> carrinho = cart.js +//-> itens = item.js diff --git a/06-shopee-cart/src/index.js b/06-shopee-cart/src/index.js index f44425f..42b6a22 100644 --- a/06-shopee-cart/src/index.js +++ b/06-shopee-cart/src/index.js @@ -1,25 +1,35 @@ -import * as cartService from "./services/cart.js"; -import createItem from "./services/item.js"; - -const myCart = []; -const myWhishList = []; - -console.log("Welcome to the your Shopee Cart!"); - -//criando dois itens -const item1 = await createItem("hotwheels ferrari", 20.99, 1); -const item2 = await createItem("hotwheels lamborghini", 39.99, 3); - -// adicionei dois itens ao carrinho -await cartService.addItem(myCart, item1); -await cartService.addItem(myCart, item2); - -await cartService.removeItem(myCart, item2); -await cartService.removeItem(myCart, item2); -await cartService.removeItem(myCart, item2); - -await cartService.displaycart(myCart); -// deletei dois itens do carrinho -// await cartService.deleteItem(myCart, item2.name); -// await cartService.deleteItem(myCart, item1.name); -await cartService.calculateTotal(myCart); +import * as cartServices from "./services/cart.js"; +import createItem from "./services/item.js"; + +const myCart = []; +const myWishList = []; + +console.log("Welcome to the your Shopee Cart!") + +const item1 = await createItem('hotwheels ferrari', 20.99, 1); +const item2 = await createItem('hotwheels lamborghini', 39.99, 3); + +//adicionado 2 itens ao carrinho +await cartServices.addItem(myCart,item1); +await cartServices.addItem(myCart,item2); + +//removendo 1 da quantidade de item +//await cartServices.removeItem(myCart, item2); +//await cartServices.removeItem(myCart, item2); + +//limpar o carrinho, remover todos os itens +await cartServices.cleanCart(myCart); + +//display do carrinho +await cartServices.displayCart(myCart); + + +//deletado 2 itens do carrinho +// await cartServices.deleteItem(myCart, item2.name) +// await cartServices.deleteItem(myCart, item1.name) + + + +await cartServices.calculateTotal(myCart); + + diff --git a/06-shopee-cart/src/services/cart.js b/06-shopee-cart/src/services/cart.js index 9f50a26..f9fb43a 100644 --- a/06-shopee-cart/src/services/cart.js +++ b/06-shopee-cart/src/services/cart.js @@ -1,62 +1,64 @@ -//quais açoes meu carrinho pode fazer - -//CASOS DE USO -// ✅ -> adicionar item no carrinho -async function addItem(userCart, item) { - userCart.push(item); -} - -// ✅ -> calcular o total do carrinho -async function calculateTotal(userCart) { - console.log("\nShopee Cart TOTAL IS:"); - - const result = userCart.reduce((total, item) => total + item.subtotal(), 0); - console.log(`🎁Total: ${result}`); -} - -// -> deletar item do carrinho -async function deleteItem(userCart, name) { - const index = userCart.findIndex((item) => item.name === name); - - if (index !== -1) { - userCart.splice(index, 1); - } -} - -// -> ✅ remover um item - diminui um item -async function removeItem(userCart, item) { - //1. encontrar o indice do item - const indexFound = userCart.findIndex((p) => p.name === item.name); - - //2. Caso não encontre o item - if (indexFound == -1) { - console.log("item não encontrado"); - return; - } - - //3. item > 1 subtrair um item - if (userCart[indexFound].quantity > 1) { - userCart[indexFound].quantity -= 1; - return; - } - - //4. caso item = 1 deletar o item - if (userCart[indexFound].quantity == 1) { - userCart.splice(indexFound, 1); - return; - } -} - -// ✅ mostra todos os items do carrinho -async function displaycart(userCart) { - console.log("\nShopee cart list:"); - userCart.forEach((item, index) => { - console.log( - `${index + 1}. ${item.name} - R$ ${item.price} | ${ - item.quantity - }x | Subtotal = ${item.subtotal()}` - ); - }); -} - -export { addItem, calculateTotal, deleteItem, removeItem, displaycart }; +//Quais ações meu carrinho pode fazer? + +//CASOS DE USO +//-> ✅adicionar item ao carrinho +async function addItem(userCart, item) { + userCart.push(item); +} +//-> ✅deletar item do carrinho +async function deleteItem(userCart, name) { + const index = userCart.findIndex((item) => item.name === name); + if (index !== -1){ + userCart.splice(index,1); + } +} +//->✅ remover um item do carrinho +async function removeItem(userCart, item) { + + //1. Encontrar o indice do item + const indexFound = userCart.findIndex((p) => p.name === item.name); + + //2. Caso não encontre o item + if(indexFound == -1){ + console.log("Item não encontrado"); + return; + } + //3. item > 1 subtrair um item + if(userCart[indexFound].quantity > 1){ + userCart[indexFound].quantity -= 1; + return; + } + //4. item = 1 deletar o item + if(userCart[indexFound].quantity == 1){ + userCart.splice(indexFound, 1); + return; + } + +} +//-> ✅calcular o valor total dos itens no carrinho +async function calculateTotal(userCart) { + console.log("\nShopee Cart TOTAL: "); + const result = userCart.reduce((total, item) => total + item.subtotal(), 0); + console.log(`💵Total: ${result}`); +} +//-> ✅display pra mostrar os itens no carrinho +async function displayCart(userCart) { + console.log("Shopee cart list:"); + userCart.forEach((item, index) => { + console.log(`${index +1}. ${item.name} - R$ ${item.price} | ${item.quantity} X | Subtotal= ${item.subtotal()}`); + }); +} +async function cleanCart(userCart) { + userCart.length = 0; + console.log("Todos itens foram removidos!!"); +} + + +export { + addItem, + deleteItem, + removeItem, + calculateTotal, + displayCart, + cleanCart, +} \ No newline at end of file diff --git a/06-shopee-cart/src/services/item.js b/06-shopee-cart/src/services/item.js index 4eaaee7..444812d 100644 --- a/06-shopee-cart/src/services/item.js +++ b/06-shopee-cart/src/services/item.js @@ -1,13 +1,13 @@ -//CASOS DE USO DOS ITENS - -// -> criar item com subtotal certo -async function createItem(name, price, quantity) { - return { - name, - price, - quantity, - subtotal: () => price * quantity, - }; -} - -export default createItem; +//CASOS DE USO + +//->Criar item com subtotal certo +async function createItem(name, price, quantity) { + return { + name, + price, + quantity, + subtotal: () => price * quantity, + }; +} + +export default createItem; \ No newline at end of file