package br.com.alura.alugames.principal
import br.com.alura.alugames.data.Database
import br.com.alura.alugames.data.plano.PlanoDAO
import br.com.alura.alugames.modelo.PlanoAssinatura
import br.com.alura.alugames.modelo.PlanoAvulso
fun main() {
val avulso = PlanoAvulso("BRONZE")
val prata = PlanoAssinatura("PRATA", 9.90, 3, 0.15)
val ouro = PlanoAssinatura("OURO", 19.90, 5, 0.20)
val platina = PlanoAssinatura("PLATINA", 29.90, 10, 0.30)
val diamante = PlanoAssinatura("DIAMANTE", 49.90, 20, 0.50)
val manager = Database.getEntityManager()
val planosDAO = PlanoDAO(manager)
planosDAO.add(avulso)
planosDAO.add(prata)
planosDAO.add(ouro)
planosDAO.add(platina)
planosDAO.add(diamante)
val listaPlanos = planosDAO.getList()
println(listaPlanos)
manager.close()
}
package br.com.alura.alugames.principal
import br.com.alura.alugames.modelo.Gamer
fun main() {
val gamer1 = Gamer("Jacque", "jacque@email.com")
println(gamer1)
val gamer2 = Gamer(
"Jeni",
"jeni@email.com",
"19/19/1992",
"jeniblo")
println(gamer2)
gamer1.let {
it.dataNascimento = "18/09/2000"
it.usuario = "jacqueskywalker"
}.also {
println(gamer1.idInterno)
}
println(gamer1)
gamer1.usuario = "jacque"
println(gamer1)
}
package br.com.alura.alugames.utilitario
import br.com.alura.alugames.data.plano.PlanoAssinaturaEntity
import br.com.alura.alugames.data.plano.PlanoAvulsoEntity
import br.com.alura.alugames.data.plano.PlanoEntity
import br.com.alura.alugames.modelo.Plano
import br.com.alura.alugames.modelo.PlanoAssinatura
import br.com.alura.alugames.modelo.PlanoAvulso
fun Plano.toEntity() : PlanoEntity{
return if (this is PlanoAssinatura) {
PlanoAssinaturaEntity(
this.tipo,
this.mensalidade,
this.jogosIncluidos,
this.percentualDescontoReputacao,
this.id
)
} else {
PlanoAvulsoEntity(
this.tipo,
this.id
)
}
}
fun PlanoEntity.toModel(): Plano{
return if (this is PlanoAssinaturaEntity) {
PlanoAssinatura(
this.tipo,
this.mensalidade,
this.jogosIncluidos,
this.percentualDescontoReputacao,
this.id
)
} else {
PlanoAvulso(
this.tipo,
this.id
)
}
}
eu fiz as alterações no BD mas ainda assim da essa mensagem do ID( agora aparecendo 25), tentei invalidar caches no intelliJ tb e n foi.