Created
June 15, 2024 11:36
-
-
Save ronieremarques/6cebd51f3005a94f529427ecce50ce63 to your computer and use it in GitHub Desktop.
This file contains 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
let campoIdade; | |
let campoFantasia; | |
let campoAventura; | |
function setup() { | |
createCanvas(800, 400); | |
createElement("h2", "Recomendador de filmes"); | |
createSpan("Sua idade:"); | |
campoIdade = createInput("5"); | |
campoFantasia = createCheckbox("Gosta de fantasia?"); | |
campoAventura = createCheckbox("Gosta de aventura?"); | |
} | |
function draw() { | |
background("white"); | |
let idade = campoIdade.value(); | |
let gostaDeFantasia = campoFantasia.checked(); | |
let gostaDeAventura = campoAventura.checked(); | |
let recomendacao = geraRecomendacao(idade, gostaDeFantasia, gostaDeAventura); | |
fill(color(76, 0, 115)); | |
textAlign(CENTER, CENTER); | |
textSize(38); | |
text(recomendacao, width / 2, height / 2); | |
} | |
function geraRecomendacao(idade, gostaDeFantasia, gostaDeAventura) { | |
if (idade >= 10) { | |
if (idade >= 14) { | |
return "O menino que descobriu o vento"; | |
} else { | |
if (idade >= 12) { | |
if(gostaDeFantasia || gostaDeAventura) { | |
return "Homem aranha: no aranhaverso"; | |
} else{ | |
return "Ladrões de bicicleta"; | |
} | |
} else { | |
if (gostaDeFantasia) { | |
return "As aventuras de pi"; | |
} else { | |
return "Depois da chuva"; | |
} | |
} | |
} | |
} else { | |
if (gostaDeFantasia) { | |
return "A viagem de chihiro"; | |
} else { | |
return "O feitiço do tempo"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment