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

challenge solved #64

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
79 changes: 68 additions & 11 deletions desafio.kt
Original file line number Diff line number Diff line change
@@ -1,21 +1,78 @@
// [Template no Kotlin Playground](https://pl.kotl.in/WcteahpyN)
enum class Level { BEGINNER, INTERMEDIATE, ADVANCED }

enum class Nivel { BASICO, INTERMEDIARIO, DIFICIL }
data class User(
val name: String,
val email: String,
val age: Int
)

class Usuario
data class EducationalContent(
val name: String,
val duration: Int = 60, // Default duration of 60 minutes
val author: String
)

data class ConteudoEducacional(var nome: String, val duracao: Int = 60)
class Course(
val name: String,
val level: Level, // Using the Level enum to represent the level
var contents: MutableList<EducationalContent> = mutableListOf()
) {
val enrolledStudents = mutableListOf<User>()

data class Formacao(val nome: String, var conteudos: List<ConteudoEducacional>) {
fun enroll(user: User) {
enrolledStudents.add(user)
println("User ${user.name} enrolled in course $name")
}

fun addContent(content: EducationalContent) {
contents.add(content)
println("Content ${content.name} added to course $name")
}

fun removeContent(content: EducationalContent) {
if (contents.remove(content)) {
println("Content ${content.name} removed from course $name")
} else {
println("Content ${content.name} not found in course $name")
}
}

val inscritos = mutableListOf<Usuario>()

fun matricular(usuario: Usuario) {
TODO("Utilize o parâmetro $usuario para simular uma matrícula (usar a lista de $inscritos).")
fun details() {
println("Course: $name")
println("Level: $level") // 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.name} (${content.duration} minutes) - (by ${content.author})")
}
}

println("Enrolled Students:")
if (enrolledStudents.isEmpty()) {
println(" No students enrolled yet.")
} else {
for (student in enrolledStudents) {
println(" - ${student.name} (${student.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 = User("Paul", "[email protected]", 35)
val user2 = User("Cleber", "[email protected]", 21)

val content1 = EducationalContent("Introduction to Kotlin", 90, "Professor A")
val content2 = EducationalContent("Introduction to Java", 120, "Professor B") // Duration changed to 120 minutes

val javaCourse = Course("Java Course", Level.INTERMEDIATE)
javaCourse.addContent(content1) // Adding the correct contents
javaCourse.addContent(content2)

javaCourse.enroll(user1)
javaCourse.enroll(user2)

javaCourse.details()
}