How to "catch" system time in Portugol Studio
I know you need to import the calendar library.But I don't know how the current time_function works.I'm trying to print on screen to test this function. Go the following code
programa{
inclua biblioteca Calendario
funcao inicio()
{
real valor
escreva("{Exercício 20 - É possivel assistir o filme?}\n\n")
escreva("{============ Cinema Estudonauta ===========\n}")
escreva("Horário do filme: 12h - Preço do ingresso: R$20,00\n")
escreva("--------------------------------------------------")
escreva("Quanto dinheiro você tem? R$")
leia(valor)
escreva(Calendario.hora_atual(formato_24h))
}
}
Desulpate code formatting.Because I still do not know how to format here in StackoverFlow.
Note: I'm using Linux distro.Does that interfere with anything?
0
1 answers
Manage to solve the exercise.And further improve it by adding system minutes to logic.The parameter of the time_atual function was true or false.That's where I was going wrong.
programa
{
inclua biblioteca Calendario
funcao inicio()
{
real valor
inteiro hora , minuto
escreva("{Exercício 20 - É possivel assistir o filme?}\n\n")
escreva("{============ Cinema Estudonauta ===========\n}")
escreva("Horário do filme: 14h - Preço do ingresso: R$20,00\n")
escreva("--------------------------------------------------\n")
escreva("Quanto dinheiro você tem? R$")
leia(valor)
hora = Calendario.hora_atual(falso))
minuto = Calendario.minuto_atual()
se(hora <= 14 e minuto < 1 e valor >=20 ){
escreva("Agora são "+hora+":"+minuto+".Você consegue comprar o ingresso!")
}senao{
escreva("Agora são "+hora+":"+minuto+". Infelizmente não é possível comprar os ingresso !")
}
}
}
0
Author: Ronan, 2020-04-08 18:16:36