mirror of
https://github.com/russok/FitoTrack.git
synced 2025-10-28 08:12:11 -07:00
Types of Goals
This commit is contained in:
parent
719d889ae9
commit
86ef7113ae
@ -0,0 +1,22 @@
|
||||
package de.tadris.fitness.recording.goal;
|
||||
|
||||
import de.tadris.fitness.R;
|
||||
|
||||
public class CalorieGoal extends Goal {
|
||||
|
||||
private int calories;
|
||||
|
||||
public CalorieGoal(int calories) {
|
||||
this.calories = calories;
|
||||
}
|
||||
|
||||
@Override
|
||||
int getName() {
|
||||
return R.string.calories;
|
||||
}
|
||||
|
||||
@Override
|
||||
double getProgress(long duration, int distance, int calories) {
|
||||
return (double) calories / this.calories;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package de.tadris.fitness.recording.goal;
|
||||
|
||||
import de.tadris.fitness.R;
|
||||
|
||||
public class DistanceGoal extends Goal {
|
||||
|
||||
private int goalDistance;
|
||||
|
||||
public DistanceGoal(int goalDistance) {
|
||||
this.goalDistance = goalDistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
int getName() {
|
||||
return R.string.workoutDistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
double getProgress(long duration, int distance, int calories) {
|
||||
return (double) distance / goalDistance;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package de.tadris.fitness.recording.goal;
|
||||
|
||||
import de.tadris.fitness.R;
|
||||
|
||||
public class DurationGoal extends Goal {
|
||||
|
||||
private long duration;
|
||||
|
||||
@Override
|
||||
int getName() {
|
||||
return R.string.workoutDuration;
|
||||
}
|
||||
|
||||
public DurationGoal(long duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
double getProgress(long duration, int distance, int calories) {
|
||||
return (double) duration / this.duration;
|
||||
}
|
||||
}
|
||||
12
app/src/main/java/de/tadris/fitness/recording/goal/Goal.java
Normal file
12
app/src/main/java/de/tadris/fitness/recording/goal/Goal.java
Normal file
@ -0,0 +1,12 @@
|
||||
package de.tadris.fitness.recording.goal;
|
||||
|
||||
import androidx.annotation.StringRes;
|
||||
|
||||
abstract public class Goal {
|
||||
|
||||
@StringRes
|
||||
abstract int getName();
|
||||
|
||||
abstract double getProgress(long duration, int distance, int calories);
|
||||
|
||||
}
|
||||
@ -62,6 +62,7 @@
|
||||
<string name="workoutBurnedEnergy">Burned Energy</string>
|
||||
<string name="workoutTotalEnergy">Total Energy</string>
|
||||
<string name="workoutEnergyConsumption">Energy Consumption</string>
|
||||
<string name="calories">Calories</string>
|
||||
|
||||
<string name="workoutAscent">Ascent</string>
|
||||
<string name="workoutDescent">Descent</string>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user