changed Time increase and decrease functions

This commit is contained in:
Lukas Barragan Torres 2023-05-03 13:53:35 +02:00
parent 853a09866a
commit e0f46d676b
5 changed files with 9 additions and 15 deletions

View file

@ -4,7 +4,7 @@ class FunctionalCustomTimer(studyTime: Int) : FunctionalTimer(studyTime) {
override fun tick() {
if (!hasEnded()) {
time.minOne()
time++
totalStudyTime++
}
}

View file

@ -11,7 +11,7 @@ class FunctionalEndlessTimer : FunctionalTimer(0) {
}
override fun tick() {
time.plusOne()
time++
totalStudyTime++
}

View file

@ -22,7 +22,7 @@ class FunctionalPomodoroTimer(
}
isInBreak = !isInBreak
}
time.minOne()
time--
if (!isInBreak) {
totalStudyTime++

View file

@ -4,7 +4,7 @@ import be.ugent.sel.studeez.data.local.models.SessionReport
import com.google.firebase.Timestamp
abstract class FunctionalTimer(initialValue: Int) {
val time: Time = Time(initialValue)
var time: Time = Time(initialValue)
var totalStudyTime: Int = 0
fun getHoursMinutesSeconds(): HoursMinutesSeconds {

View file

@ -1,19 +1,13 @@
package be.ugent.sel.studeez.data.local.models.timer_functional
class Time(initialTime: Int) {
class Time(var time: Int) {
operator fun invoke() = time
var time = initialTime
operator fun inc(): Time = Time(time + 1)
fun minOne() {
time--
}
fun plusOne() {
time++
}
operator fun dec(): Time = Time(time - 1)
fun getAsHMS(): HoursMinutesSeconds {
return HoursMinutesSeconds(time)
}
}
}