-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #216 from SWM-KAWAI-MANS/release/v1.1.0
Release/v1.1.0
- Loading branch information
Showing
28 changed files
with
502 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...rc/main/java/online/partyrun/partyrunapplication/core/model/single/SingleTargetDetails.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package online.partyrun.partyrunapplication.core.model.single | ||
|
||
data class SingleTargetDetails( | ||
val distance: Int = INITIAL_DISTANCE, | ||
val time: Int = INITIAL_TIME | ||
) { | ||
companion object { | ||
const val INITIAL_DISTANCE = 5000 // 'm' 단위 | ||
const val INITIAL_TIME = 900 // '초' 단위, 900초 = 15분 | ||
const val DISTANCE_INCREMENT = 250 | ||
const val TIME_INCREMENT = 300 | ||
const val SECONDS_IN_HOUR = 3600 | ||
const val SECONDS_IN_MINUTE = 60 | ||
} | ||
} | ||
|
||
fun SingleTargetDetails.incrementDistance(): SingleTargetDetails { | ||
return copy(distance = this.distance + SingleTargetDetails.DISTANCE_INCREMENT) | ||
} | ||
|
||
fun SingleTargetDetails.decrementDistance(): SingleTargetDetails { | ||
if (this.distance > SingleTargetDetails.DISTANCE_INCREMENT) { | ||
return copy(distance = this.distance - SingleTargetDetails.DISTANCE_INCREMENT) | ||
} | ||
return this | ||
} | ||
|
||
fun SingleTargetDetails.incrementTime(): SingleTargetDetails { | ||
return copy(time = this.time + SingleTargetDetails.TIME_INCREMENT) | ||
} | ||
|
||
fun SingleTargetDetails.decrementTime(): SingleTargetDetails { | ||
if (this.time > SingleTargetDetails.TIME_INCREMENT) { | ||
return copy(time = this.time - SingleTargetDetails.TIME_INCREMENT) | ||
} | ||
return this | ||
} | ||
|
||
fun SingleTargetDetails.getFormattedTime(): String { | ||
val hours = this.time / SingleTargetDetails.SECONDS_IN_HOUR | ||
val remainingTime = this.time % SingleTargetDetails.SECONDS_IN_HOUR | ||
val minutes = remainingTime / SingleTargetDetails.SECONDS_IN_MINUTE | ||
return String.format("%02d:%02d", hours, minutes) | ||
} | ||
|
||
fun SingleTargetDetails.getFormattedDistance(): String { | ||
return String.format("%04.2f", (this.distance.toFloat() / 1000f) * 100f / 100) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.