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

Commit do exercicio OOP #65

Open
wants to merge 2 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
66 changes: 57 additions & 9 deletions desafio.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConteudoEducacional>) {
class Curso(val nome: String, val nivel: Nivel, var contents: MutableList<ConteudoEducacional> = mutableListOf()) {

val inscritos = mutableListOf<Usuario>()

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", "[email protected]", 35)
val user2 = Usuario("Cleber", "[email protected]", 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()
}