Computer scienceProgramming languagesKotlinObject-oriented programmingSpecial constructions / Special classes

Object declarations

Manager

Report a typo

You want to create a singleton Manager that can solve some tasks. Let's write a skeleton for it.

First, you have a class Task with one field name. Second, you need to create a singleton Manager with a function solveTask() and an Int property solvedTask.

The function solveTask() receives an instance of the Task class and prints a line "Task NAME solved!", where NAME is the name of the task.

Also, you should increase the solvedTask property by one each time you solve a task. Good luck!

Write a program in Kotlin
class Task(val name: String)

// create the Manager singleton here
___

Create a free account to access the full topic