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() { override fun tick() {
if (!hasEnded()) { if (!hasEnded()) {
time.minOne() time++
totalStudyTime++ totalStudyTime++
} }
} }

View file

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

View file

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

View file

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

View file

@ -1,19 +1,13 @@
package be.ugent.sel.studeez.data.local.models.timer_functional 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() { operator fun dec(): Time = Time(time - 1)
time--
}
fun plusOne() {
time++
}
fun getAsHMS(): HoursMinutesSeconds { fun getAsHMS(): HoursMinutesSeconds {
return HoursMinutesSeconds(time) return HoursMinutesSeconds(time)
} }
}
}