City population

Report a typo

Imagine we want to implement the City class which stores the name of the city and its population.

There are some restrictions. If the number is out of range, the population is corrected like this: zero for negative values and 50 million for greater than 50_000_000.

Finish the implementation of the City class following this logic.

Write a program in Kotlin
class City(val name: String) {
var population: Int
}
___

Create a free account to access the full topic