We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
// User data class User( val name: String, val age: Int, ) // UserManagementSystem class UserManagementSystem { companion object { const val ADULT_AGE: Int = 18 } private val users = mutableListOf<User>() fun addUser( name: String, age: Int, ) { users.add(User(name, age)) } fun getAdultUsers(): List<User> = users.filter { it.age >= ADULT_AGE } fun printUserNames() = users.forEach { println(it.name) } fun calculateAverageAge(): Double = users.map { it.age }.average() } // main fun main() { val system = UserManagementSystem() // 사용자 추가 val userList = listOf( User("옥순", 25), User("옥순", 25), User("상철", 17), User("영철", 30), ) userList.forEach { system.addUser(it.name, it.age) } println("모든 사용자 이름:" + system.calculateAverageAge()) println("\n성인 사용자:") system .getAdultUsers() .forEach { println("${it.name} : (${it.age}살)") } println("\n평균 나이: ${system.calculateAverageAge()}") }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: