diff --git a/README.md b/README.md index da5dfd34..26dea4a7 100644 --- a/README.md +++ b/README.md @@ -6,5 +6,5 @@ Desafio de Projeto criado para avaliação do conteúdo técnico explorado no re ```kotlin -TODO("Crie uma solução em Koltin abstraindo esse domínio. O arquivo [desafio.kt] te ajudará 😉") +Solução de Desafio de Projeto (LAB) desenvolvida por mim : Tiago Ribeiro Santos ``` diff --git a/desafio.kt b/desafio.kt index f2ebe619..aceaecce 100644 --- a/desafio.kt +++ b/desafio.kt @@ -2,20 +2,68 @@ enum class Nivel { BASICO, INTERMEDIARIO, DIFICIL } -class Usuario +data class Usuario(val nome: String, val email: String, val age: Int) +- +data class ConteudoEducacional(val nome: String, val duracao: Int = 60, val author: String) -data class ConteudoEducacional(var nome: String, val duracao: Int = 60) - -data class Formacao(val nome: String, var conteudos: List) { +class Curso(val nome: String, val nivel: Nivel, var contents: MutableList = mutableListOf()) { val inscritos = mutableListOf() - + fun matricular(usuario: Usuario) { - TODO("Utilize o parâmetro $usuario para simular uma matrícula (usar a lista de $inscritos).") + inscritos.add(usuario) + println("Usuario ${usuario.nome} added ti course $nome") + } + + fun addContent(content: ConteudoEducacional) { + contents.add(content) + println("Content ${content.nome} added to course $nome") + } + + fun removeContent(content: ConteudoEducacional) { + if (contents.remove(content)) { + println("Content ${content.nome} removed from course $nome") + } else { + println("Content ${content.nome} not found in course $nome") + } + } + + fun details() { + println("Course: $nome") + println("Level: $nivel") // Prints the name of the level (e.g., "INTERMEDIATE") + println("Contents:") + if (contents.isEmpty()) { + println(" No content added yet.") + } else { + for (content in contents) { + println(" - ${content.nome} (${content.duracao} minutes) - (by ${content.author})") + } + } + + println("Enrolled Students:") + if (inscritos.isEmpty()) { + println(" No students enrolled yet.") + } else { + for (inscrito in inscritos) { + println(" - ${inscrito.nome} (${inscrito.email})") + } + } } } fun main() { - TODO("Analise as classes modeladas para este domínio de aplicação e pense em formas de evoluí-las.") - TODO("Simule alguns cenários de teste. Para isso, crie alguns objetos usando as classes em questão.") -} + val user1 = Usuario("Paul", "paul@gmail.com", 35) + val user2 = Usuario("Cleber", "ckb@gmail.com", 21) + + val content1 = ConteudoEducacional("Introduction to Kotlin", 90, "Professor A") + val content2 = ConteudoEducacional("Introduction to Java", 120, "Professor B") // Duration changed to 120 minutes + + val javaCourse = Curso("Java Course", Nivel.INTERMEDIARIO) + javaCourse.addContent(content1) // Adding the correct contents + javaCourse.addContent(content2) + + javaCourse.matricular(user1) + javaCourse.matricular(user2) + + javaCourse.details() +} \ No newline at end of file