Homework 2: Simple Kotlin

Due April 5

In this assignment, you will get to play around with Kotlin programming language at a deeper level.

A generally good understanding of how debugString work will also be extremely useful for this assignment.

Always refer to the Assignment section for any changes to the assignment.

Prerequisites

In order to run your test script, you must ensure that the following items have been completed:

Running your test script

You can do so by executing the command kotlinc -script main.kts in your Terminal.

debugString

debugString is a read-only string. A property that is declared as read-only must use the val keyword.

Getters & Setters

It is important to be familiar with how getters and setters are initialized inside a class.

Here is an example of a get() and set() method:

var stringRepresentation: String
    get() = this.toString()
    set(value) {
        setDataFromString(value) // parses the string and assigns values to other properties
    }

Last updated