Creating a Data Class
In the project tool window, right-click the com.bignerdranch.android.criminalintent package and select New → Kotlin File/Class to create a file named Crime.kt.
In Crime.kt, add fields to represent the crime’s ID, title, date, and status and a constructor that initializes the ID and date fields.
In addition to the fields, add the
data keyword to the class definition to make Crime a data class.
Listing 8.1 Adding the
Crime data class (
data class Crime(val id: UUID = UUID.randomUUID(), var title: String = "", var date: Date = Date(), var isSolved: Boolean = false)
When importing Date, you will be presented with multiple options. Make sure to import java.util.Date.
UUID is a utility class ...