-
Notifications
You must be signed in to change notification settings - Fork 21
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 #34 from GledsonAfonso/master
Adding pace calculation to SpeedCalculator (issue #15)
- Loading branch information
Showing
7 changed files
with
191 additions
and
7 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
33 changes: 33 additions & 0 deletions
33
src/main/java/segelzwerg/sporttooolbox/IUnits/MinutesPerHundredMeters.java
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,33 @@ | ||
package segelzwerg.sporttooolbox.IUnits; | ||
|
||
import lombok.EqualsAndHashCode; | ||
|
||
/** | ||
* Pace of minutes per hundred meters | ||
*/ | ||
@EqualsAndHashCode | ||
public class MinutesPerHundredMeters implements Pace { | ||
private final float pace; | ||
|
||
public MinutesPerHundredMeters(float pace) { | ||
this.pace = pace; | ||
} | ||
|
||
/** | ||
* Converting to minutes per kilometers | ||
* @return Pace instance with a converted numeric value | ||
*/ | ||
@Override | ||
public Pace toMinutesPerKilometer() { | ||
return new MinutesPerKilometer(pace * PER_HUNDRED_METER_TO_PER_KILOMETER); | ||
} | ||
|
||
/** | ||
* Converting to minutes per hundred meters | ||
* @return itself, since there's no conversion to be made | ||
*/ | ||
@Override | ||
public Pace toMinutesPerHundredMeters() { | ||
return this; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/segelzwerg/sporttooolbox/IUnits/MinutesPerKilometer.java
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,33 @@ | ||
package segelzwerg.sporttooolbox.IUnits; | ||
|
||
import lombok.EqualsAndHashCode; | ||
|
||
/** | ||
* Pace of minutes per kilometers | ||
*/ | ||
@EqualsAndHashCode | ||
public class MinutesPerKilometer implements Pace { | ||
private final float pace; | ||
|
||
public MinutesPerKilometer(float pace) { | ||
this.pace = pace; | ||
} | ||
|
||
/** | ||
* Converting to minutes per kilometers | ||
* @return itself, since there's no conversion to be made | ||
*/ | ||
@Override | ||
public Pace toMinutesPerKilometer() { | ||
return this; | ||
} | ||
|
||
/** | ||
* Converting to minutes per hundred meters | ||
* @return Pace instance with a converted numeric value | ||
*/ | ||
@Override | ||
public Pace toMinutesPerHundredMeters() { | ||
return new MinutesPerHundredMeters(pace * PER_KILOMETER_TO_PER_HUNDRED_METER); | ||
} | ||
} |
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,22 @@ | ||
package segelzwerg.sporttooolbox.IUnits; | ||
|
||
/** | ||
* Pace interface | ||
*/ | ||
public interface Pace { | ||
float KILO = 1000.0f; | ||
float PER_KILOMETER_TO_PER_HUNDRED_METER = 0.1f; | ||
float PER_HUNDRED_METER_TO_PER_KILOMETER = 10.0f; | ||
|
||
/** | ||
* Converts to minutes per kilometers | ||
* @return an instance of Pace | ||
*/ | ||
Pace toMinutesPerKilometer(); | ||
|
||
/** | ||
* Converts to minutes per hundred-meters | ||
* @return an instance of Pace | ||
*/ | ||
Pace toMinutesPerHundredMeters(); | ||
} |
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