Your task is to complete a simple Kotlin program that models a Car entity. The Car object should have a constructor that takes three parameters - brand, model, and year, all of which should be initialized using named arguments during object creation. Also, each time a new Car object is created, it should print out a statement displaying the car's brand, model, and year. Fill the blanks in the code to make it work as expected.
Computer scienceProgramming languagesKotlinObject-oriented programmingObject-oriented programming basic
Constructors
Creating a Car entity in a program
Report a typo
Fill in the gaps with the relevant elements
Car( brand: String, val model: String, val year: Int) {
{
println("Car brand: $brand, Model: $model, Year: $year")
}
}
main() {
val car1 = Car(brand = "Toyota", model = "Corolla", year = 2020)
}Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.