We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fd83492 commit b81fab0Copy full SHA for b81fab0
Conventions/Comparison/src/Task.kt
@@ -1,5 +1,13 @@
1
+import java.util.*
2
+
3
data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) : Comparable<MyDate> {
- /* TODO */
4
+ override fun compareTo(other: MyDate): Int {
5
+ val firstDate = Calendar.getInstance()
6
+ firstDate.set(year, month, dayOfMonth)
7
+ val secondDate = Calendar.getInstance()
8
+ secondDate.set(other.year, other.month, other.dayOfMonth)
9
+ return firstDate.compareTo(secondDate)
10
+ }
11
}
12
13
fun compare(date1: MyDate, date2: MyDate) = date1 < date2
0 commit comments