Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entrega do projeto #200

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added imagens/abacate.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imagens/abacaxi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imagens/banana.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imagens/basket-love.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imagens/bergamota.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions imagens/github-icon-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imagens/goiaba.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imagens/laranja.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imagens/limao.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imagens/maca.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imagens/mamao.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imagens/manga.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imagens/maracuja.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imagens/pera.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imagens/uva.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions projeto.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Projeto intro web</title>
<script src="projeto.js" defer></script>
<link rel="stylesheet" href="style.css">
</head>

<body>
<header class="header">
<div class="titulo">
<h3 class="cesta">Cesta de frutas</h3>
<img src="./imagens/basket-love.png" alt="basket image" height="80" widht="80">
</div>
<div class="busca">
<input type="text" placeholder="Digite a fruta!" id="buscador">
<button class="botao" onclick="buscarFruta(event)">Buscar</button>
<button class="botao" onclick="retornarHome()">Retornar</button>
</div>
</header>
<main class="main">
<div class="conteudo" id="selecao"></div>
</main>
<footer class="footer">
Desenvolvido por Éverson Andrade!
<a href="https://github.com/everandrade"><img src="./imagens/github-icon-1.svg" alt="Github Icon" height="30"
widht="30"></a>
</footer>
</body>

</html>
263 changes: 263 additions & 0 deletions projeto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
FrutaA = {
imagem: "./imagens/abacate.jpg",
nome: "ABACATE",
peso: "1 unidade",
preco: 6.39,
saborDoce: true,
marca: ["Rocha", " Antunes"],
}

FrutaB = {
imagem: "./imagens/abacaxi.jpg",
nome: "ABACAXI",
peso: "1 unidade",
preco: 10.49,
saborDoce: true,
marca: ["Faria", " Agco"],
}

FrutaC = {
imagem: "./imagens/banana.jpg",
nome: "BANANA CATURRA",
peso: "500 gramas",
preco: 3.99,
saborDoce: true,
marca: ["Deere", " CNH"],
}

FrutaD = {
imagem: "./imagens/bergamota.jpg",
nome: "BERGAMOTA",
peso: "500 gramas",
preco: 3.99,
saborDoce: true,
marca: ["Farming", " Claas"],
}

FrutaE = {
imagem: "./imagens/goiaba.jpg",
nome: "GOIABA",
peso: "500 gramas",
preco: 6.19,
saborDoce: true,
marca: ["Igu", " Masso"],
}

FrutaF = {
imagem: "./imagens/laranja.jpg",
nome: "LARANJA",
peso: "500 gramas",
preco: 2.99,
saborDoce: true,
marca: ["Toshi", " Holland"],
}

FrutaG = {
imagem: "./imagens/limao.jpg",
nome: "LIMÃO",
peso: "500 gramas",
preco: 5.89,
saborDoce: false,
marca: ["Massei", " Ferro"],
}

FrutaH = {
imagem: "./imagens/maca.jpg",
nome: "MAÇÃ",
peso: "500 gramas",
preco: 5.29,
saborDoce: true,
marca: ["Hurli", " Silva"],
}

FrutaI = {
imagem: "./imagens/mamao.jpg",
nome: "MAMÃO",
peso: "1 unidade",
preco: 7.89,
saborDoce: true,
marca: ["Green", " Santo"],
}

FrutaJ = {
imagem: "./imagens/manga.jpg",
nome: "MANGA",
peso: "1 unidade",
preco: 6.59,
saborDoce: true,
marca: ["Costa", " Antunes"],
}

FrutaK = {
imagem: "./imagens/maracuja.jpg",
nome: "MARACUJÁ DOCE",
peso: "500 gramas",
preco: 8.89,
saborDoce: true,
marca: ["Arturo", " Iha"],
}

FrutaL = {
imagem: "./imagens/pera.jpg",
nome: "PÊRA",
peso: "500 gramas",
preco: 9.15,
saborDoce: true,
marca: ["Afo", " Noxx"],
}

FrutaM = {
imagem: "./imagens/uva.jpg",
nome: "UVA",
peso: "500 gramas",
preco: 8.57,
saborDoce: true,
marca: ["Roxo", " Meira"],
}

//média dos preços:

let mediaPreco = (FrutaA.preco + FrutaB.preco + FrutaC.preco + FrutaD.preco + FrutaE.preco + FrutaF.preco + FrutaG.preco + FrutaH.preco + FrutaI.preco + FrutaJ.preco + FrutaK.preco + FrutaL.preco + FrutaM.preco)/13
console.log(`A média dos preços das frutas é de: ${mediaPreco.toFixed(2)} reais.`);


let cestaFruta = [FrutaA, FrutaB, FrutaC, FrutaD, FrutaE, FrutaF, FrutaG, FrutaH, FrutaI, FrutaJ, FrutaK, FrutaL, FrutaM]

for (let i in cestaFruta) {
cestaFruta[i].marca = cestaFruta[i].marca.toString()
}

//impressão de relatório:
console.log(cestaFruta);

//verificação do valor booleano:
if (FrutaA.saborDoce) {
console.log(`A fruta ${FrutaA.nome.toLowerCase()} é doce!`)
} else {
console.log(`A fruta ${FrutaA.nome.toLowerCase()} não é doce!`)
}
if (FrutaB.saborDoce) {
console.log(`A fruta ${FrutaB.nome.toLowerCase()} é doce!`)
} else {
console.log(`A fruta ${FrutaB.nome.toLowerCase()} não é doce!`)
}
if (FrutaC.saborDoce) {
console.log(`A fruta ${FrutaC.nome.toLowerCase()} é doce!`)
} else {
console.log(`A fruta ${FrutaC.nome.toLowerCase()} não é doce!`)
}
if (FrutaD.saborDoce) {
console.log(`A fruta ${FrutaD.nome.toLowerCase()} é doce!`)
} else {
console.log(`A fruta ${FrutaD.nome.toLowerCase()} não é doce!`)
}
if (FrutaE.saborDoce) {
console.log(`A fruta ${FrutaE.nome.toLowerCase()} é doce!`)
} else {
console.log(`A fruta ${FrutaE.nome.toLowerCase()} não é doce!`)
}
if (FrutaF.saborDoce) {
console.log(`A fruta ${FrutaF.nome.toLowerCase()} é doce!`)
} else {
console.log(`A fruta ${FrutaF.nome.toLowerCase()} não é doce!`)
}
if (FrutaG.saborDoce) {
console.log(`A fruta ${FrutaG.nome.toLowerCase()} é doce!`)
} else {
console.log(`A fruta ${FrutaG.nome.toLowerCase()} não é doce!`)
}
if (FrutaH.saborDoce) {
console.log(`A fruta ${FrutaH.nome.toLowerCase()} é doce!`)
} else {
console.log(`A fruta ${FrutaH.nome.toLowerCase()} não é doce!`)
}
if (FrutaI.saborDoce) {
console.log(`A fruta ${FrutaI.nome.toLowerCase()} é doce!`)
} else {
console.log(`A fruta ${FrutaI.nome.toLowerCase()} não é doce!`)
}
if (FrutaJ.saborDoce) {
console.log(`A fruta ${FrutaJ.nome.toLowerCase()} é doce!`)
} else {
console.log(`A fruta ${FrutaJ.nome.toLowerCase()} não é doce!`)
}
if (FrutaK.saborDoce) {
console.log(`A fruta ${FrutaK.nome.toLowerCase()} é doce!`)
} else {
console.log(`A fruta ${FrutaK.nome.toLowerCase()} não é doce!`)
}
if (FrutaL.saborDoce) {
console.log(`A fruta ${FrutaL.nome.toLowerCase()} é doce!`)
} else {
console.log(`A fruta ${FrutaL.nome.toLowerCase()} não é doce!`)
}
if (FrutaM.saborDoce) {
console.log(`A fruta ${FrutaM.nome.toLowerCase()} é doce!`)
} else {
console.log(`A fruta ${FrutaM.nome.toLowerCase()} não é doce!`)
}

// let novaCestaArray = [...cestaFruta]

novaCestaArray = document.querySelector(".conteudo");

cestaFruta.filter(p => {
function listarCesta() {
novaCestaArray.innerHTML += `
<section class="item">
<ul class="item-descricao">
<img src="${p.imagem}" alt="imagem da fruta" height="80" widht="80">
<div class="fruta">
<p>${p.nome}</p>
<p>${p.peso}</p>
<p>R$ ${p.preco}</p>
<p>Sabor doce: ${p.saborDoce}</p>
<p>Marcas: ${p.marca}</p>
<button id="botao-compra" onclick="comprarItem()">Comprar</button>
</div>
</ul>
</section>`
}
listarCesta()
})

function buscarFruta(event) {
event.preventDefault()
let novaCesta = document.getElementById("selecao")
let nomeFruta = document.getElementById("buscador").value.toLocaleUpperCase()
if (nomeFruta === "") {
alert("Sua busca está vazia!")
document.getElementById("buscador").value = " ";
return;
}
for (let i = 0; i < cestaFruta.length; i++) {
if (nomeFruta === cestaFruta[i].nome) {
return (novaCesta.innerHTML) = `
<section class="item">
<ul class="item-descricao">
<img src="${cestaFruta[i].imagem}" alt="imagem da fruta" height="80" widht="80">
<div class="fruta">
<p>${cestaFruta[i].nome}</p>
<p>${cestaFruta[i].peso}</p>
<p>R$ ${cestaFruta[i].preco}</p>
<p>Sabor doce: ${cestaFruta[i].saborDoce}</p>
<p>Marcas: ${cestaFruta[i].marca}</p>
<button id="botao-compra" onclick="comprarItem()">Comprar</button>
</div>
</ul>
</section>`
}
}

alert("Não foi encontrado o seu item!")
document.getElementById("buscador").value = "";
return;
};

function comprarItem() {
alert("Adicionado ao carrinho!")
}

retornarHome = () =>{
location.reload()
}
Loading