homework - isel-leic-tds/2223i.LI32D GitHub Wiki
Share your source code with user fmcarvalho
in a private Github repository named isel-tds-2223-your_number
.
Implement the NaifDate
class and its member functions nextMonth(): Int
and addDays(inc: Int): NaifDate
according to the following behavior:
println(NaifDate(28, 10, 2022).nextMonth()) // 11
println(NaifDate(28, 11, 2022).nextMonth()) // 12
println(NaifDate(28, 12, 2022).nextMonth()) // 1
println(NaifDate(28, 9, 2022).addDays(73)) // 10-12-2022
println(NaifDate(28, 9, 2022).addDays(117)) // 23-01-2023
val d2 = NaifDate(28, 12, 2022)
println(d2.addDays(43)) // 9-2-2023
Define the new class FixedStack
that implements the interface Stack
with an immutable approach.
interface Stack<T> {
fun push(item: T) : Stack<T>
fun peek(): T
fun isEmpty(): Boolean
fun pop(): Stack<T>
} |
class FixedStack<T> : Stack<T>{
private val head : Node<T>? = null
override fun push(item: T): Stack<T> = TODO("Not yet implemented")
override fun peek(): T = TODO("Not yet implemented")
override fun isEmpty(): Boolean = TODO("Not yet implemented")
override fun pop(): Stack<T> = TODO("Not yet implemented")
} |
Fix bug in addDays(days: Int)
of NaifDate
of lesson 4 and implement unit tests to check the correct behavior of NaifDate
.
Implement a new version of NaifDate
with a strongly typed Month
rather than an Int
.