Skip to content

Conversation

github-classroom[bot]
Copy link

@github-classroom github-classroom bot commented Sep 9, 2025

👋! GitHub Classroom created this pull request as a place for your teacher to leave feedback on your work. It will update automatically. Don’t close or merge this pull request, unless you’re instructed to do so by your teacher.
In this pull request, your teacher can leave comments and feedback on your code. Click the Subscribe button to be notified if that happens.
Click the Files changed or Commits tab to see all of the changes pushed to the default branch since the assignment started. Your teacher can see this too.

Notes for teachers

Use this PR to leave feedback. Here are some tips:

  • Click the Files changed tab to see all of the changes pushed to the default branch since the assignment started. To leave comments on specific lines of code, put your cursor over a line of code and click the blue + (plus sign). To learn more about comments, read “Commenting on a pull request”.
  • Click the Commits tab to see the commits pushed to the default branch. Click a commit to see specific changes.
  • If you turned on autograding, then click the Checks tab to see the results.
  • This page is an overview. It shows commits, line comments, and general comments. You can leave a general comment below.
    For more information about this pull request, read “Leaving assignment feedback in GitHub”.

Subscribed: @Tyreviel

Copy link

github-actions bot commented Sep 9, 2025

What's Working Well

Good use of the ElpriserAPI for data retrieval and proper handling of command-line arguments with picocli. The sliding window algorithm for charging optimization is correctly implemented.

Areas for Improvement

Issue: In ElprisCLI.java line 65-71, the logic for fetching next day's prices only runs after 13:00, but doesn't check if tomorrow's data is actually available.

Suggestion: Add a null/empty check before adding tomorrow's prices:

if (imorgon != null && !imorgon.isEmpty()) priser.addAll(imorgon);

Issue: In ElprisCLI.java line 120-121, the max price output format is inconsistent with the min price format.

Suggestion: Format the max price output consistently:

String maxStart = String.format("%02d", dyrast.getHour());
String maxEnd = String.format("%02d", dyrast.plusHours(1).getHour());
System.out.printf("Högsta pris: %.4f SEK/kWh kl %s-%s%n", max, maxStart, maxEnd);

Issue: In ElprisCLI.java line 154, the charging window calculation doesn't handle price ties correctly (should select earliest window).

Suggestion: Modify the sliding window algorithm to break ties by selecting the earliest window:

if (sum < minSum || (sum == minSum && i < startIndex)) {
    minSum = sum;
    startIndex = i;
}

Issue: In ElprisCLI.java line 88-89, the API call doesn't handle the case where api.getPriser() returns null.

Suggestion: Add null checks:

List<ElpriserAPI.Elpris> idag = api.getPriser(datum, klass);
if (idag != null) priser.addAll(idag);

Summary

The core functionality works well, but needs better error handling and consistency in output formatting to meet all requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant