Skip to content

Commit

Permalink
Adds longest run and tallest run calculation (#159)
Browse files Browse the repository at this point in the history
Implement logic for longest run and tallest run 

<img width="250" alt="Screenshot 2024-04-07 at 11 58 05 PM"
src="https://github.com/rilling/OpenTracks-Winter-SOEN-6431_2024/assets/46266703/b16720ca-360e-45a7-9bec-910d4c31991b">


**Link to the the issue**
#105
  • Loading branch information
chauhan9674 authored Apr 8, 2024
2 parents 012793e + 80039a3 commit e956cc9
Showing 1 changed file with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected void onCreate(Bundle savedInstanceState) {
VerticalMList[i] = new ArrayList<>();

for (int j = 0; j < size; j++) {
VerticalMList[i].add(random.nextInt(1000)); // Generating random integers between 0 and 999
VerticalMList[i].add(random.nextInt(1000));
}
}

Expand All @@ -100,7 +100,7 @@ protected void onCreate(Bundle savedInstanceState) {
for (int i = 0; i < n; i++) {
DistanceKMs[i] = new ArrayList<>();
for (int j = 0; j < size; j++) {
DistanceKMs[i].add((int) (random.nextDouble() * 20)); // Generating random integers between 0 and 999
DistanceKMs[i].add((int) (random.nextDouble() * 20));
}
}

Expand All @@ -119,12 +119,30 @@ protected void onCreate(Bundle savedInstanceState) {
}
}

ArrayList<Integer>[] tallestRun = new ArrayList[n];

for (int i = 0; i < n; i++) {
tallestRun[i] = new ArrayList<>();
for (int j = 0; j < size; j++) {
tallestRun[i].add((int) (random.nextDouble() * 100));
}
}

ArrayList<Integer>[] longestRun = new ArrayList[n];

for (int i = 0; i < n; i++) {
longestRun[i] = new ArrayList<>();
for (int j = 0; j < size; j++) {
longestRun[i].add((int) (random.nextDouble() * 10));
}
}


ArrayList<DummySeason> seasonArrayList = new ArrayList<>();
for (int i = 0; i < 4; i++) {
Days[i] = Integer.toString(random.nextInt(1001));
VerticalM[i] = calculateSum(VerticalMList[i]);
Runs[i] = random.nextInt(20);
Runs[i] = calculateSum(longestRun[i]);
DistanceKM[i] = calculateSum(DistanceKMs[i]);
Resort[i] = random.nextInt(10) + 1;
int hours = calculateSum(Hours[i]);
Expand All @@ -133,9 +151,9 @@ protected void onCreate(Bundle savedInstanceState) {
String activeTime = String.format("%02d:%02d:%02d", hours, minutes, seconds);
Active[i] = activeTime;
MaxSpeed[i] = maxSpeed(DistanceKMs[i],Hours[i]);
TallestRun[i] = (int) (random.nextDouble() * 100);
TallestRun[i] = findMax(tallestRun[i]);
MaxAltitude[i] = findMax(VerticalMList[i]);
LongestRun[i] = random.nextDouble() * 10;
LongestRun[i] = findMax(longestRun[i]);

seasonArrayList.add(new DummySeason(seasonNames[i], Integer.parseInt(Days[i]), Runs[i], Resort[i], VerticalM[i], DistanceKM[i], Active[i], MaxSpeed[i], MaxAltitude[i], TallestRun[i], LongestRun[i]));
}
Expand Down

0 comments on commit e956cc9

Please sign in to comment.