Skip to content

Instantly share code, notes, and snippets.

@oanabejenaru
Last active May 13, 2022 15:58
Show Gist options
  • Save oanabejenaru/3faf395bc3b5211750929617d5bf2305 to your computer and use it in GitHub Desktop.
Save oanabejenaru/3faf395bc3b5211750929617d5bf2305 to your computer and use it in GitHub Desktop.
fun main() {
val teachers = mutableListOf<Teacher>()
for (i in 0..2) {
teachers += Teacher("teacher $i", "teacher$i@faculty.ro")
}
val courses = mutableListOf<Course>()
for (i in 0..2) {
courses += Course("course $i", teachers[i], 2)
}
val students = mutableListOf<Student>()
for (i in 0..5) {
val student = Student("student $i", "student$i@faculty.ro", (i + 5).toDouble())
student.setPreferredCourses(*courses.toTypedArray())
students += student
}
val faculty = Faculty()
faculty.assignStudentsToCourses(students)
for (course in courses) {
println(course.name)
for (enrolledStudent in course.enrolledStudents) {
print("${enrolledStudent.name} ${enrolledStudent.grade} ||")
}
println()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment