Skip to content

Conversation

@github-classroom
Copy link

@github-classroom github-classroom bot commented Oct 6, 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: @gurkvatten

@github-actions
Copy link

github-actions bot commented Oct 6, 2025

🤖 AI Feedback

🕒 Posted on 2025-10-24T06:49:08.069Z

Overall Feedback

Looks good! Implementation passes all BasicTest and most EdgeCaseTest scenarios with excellent design and adherence to requirements. Excellent work on core features and edge cases.

Areas for Improvement

WarehouseAnalyzer Implementation

  • Weighted Average Calculation:
    The calculateWeightedAveragePriceByCategory() method uses double for weightSum, which can cause precision errors when accumulating BigDecimal weights. Switch to BigDecimal for all weight summations to ensure exact calculations.

  • Price Outliers Logic:
    The getQuartile() method is properly implemented but unused in findPriceOutliers(). The current mean/standard deviation approach fails EdgeCaseTest scenarios. Use the quartile-based IQR method as intended: replace mean/standard deviation with Q1/Q3/IQR calculation using getQuartile().

  • Shipping Group Optimization:
    The First-Fit Decreasing algorithm is incomplete. It currently processes items in sorted order but doesn't handle edge cases like partial bin fills efficiently. Consider using a true bin-packing algorithm and verify with EdgeCaseTest scenarios for max 10.0kg groups.

WarehouseAnalyzer Business Logic

  • Expiration Discounts:
    The discount logic for "within 3 days" only applies to exactly 3-day expirations. Expand condition to include 2-3 day ranges:

    else if (daysBetween >= 2 && daysBetween <= 3) { // Fix to cover 2-3 days
        discounted = p.price().multiply(new BigDecimal("0.85"));
    }
  • Inventory Validation:
    The fixed $1000 high-value threshold is arbitrary. Implement dynamic threshold calculation (test requires percentage-based approach). Split into two columns:

    long highValueCount = items.stream()
        .filter(p -> p.price().compareTo(BigDecimal.valueOf(1000)) >= 0) // Fix to dynamic threshold
        .count();

Summary

Fix precision errors in weighted averages and outlier calculation algorithms. Implement correct expiration discount ranges. The solution is mostly complete with minor logical adjustments needed for statistical accuracy.


Previous Feedback

🕒 Posted on 2025-10-23T13:44:07.504Z

Overall Feedback

The implementation demonstrates strong understanding of the assignment requirements, showing good grasp of object-oriented principles and Java features. The warehouse analytics implement complex business logic correctly in most areas, though several precision and edge case details need refinement.

What's Working Well

  • Solid foundation for core classes like Product hierarchy, interfaces, and Category value object
  • Correct handling of singleton pattern in Warehouse implementation
  • Accurate polymorphic behavior through abstract methods and interfaces
  • Proper BigDecimal usage throughout price calculations with rounding

Areas for Improvement

  1. WarehouseAnalyzer constructor mismatch (Line 5)
    Test expects new WarehouseAnalyzer(warehouse) but implementation requires this(warehouse);. Update constructor to accept Warehouse parameter.

  2. Weighted average precision (Line 274)
    Using double for weight accumulation introduces rounding errors. Convert to BigDecimal for exact calculations.

  3. Quartile calculation overflow (Line 240)
    The (n-1)*position formula can cause integer overflow for large datasets. Use (double)(n-1)*position for safety.

  4. Exception handling in expiredProducts (Line 56)
    Missing null check before calling isExpired() on potentially non-perishable items. Add null check validation.

  5. Shipping optimization missing validation (Line 351)
    Should validate maxWeightPerGroup is positive. Add check with IllegalArgumentException.

  6. Discount calculation rounding (Line 316)
    The 0.5, 0.7 and 0.85 multipliers should use BigDecimal for consistent rounding:
    value.multiply(new BigDecimal("0.50"))

  7. Warehouse getProductById (Line 45)
    Should return deep copy for product references. Override with Optional.ofNullable().

  8. Product class inconsistent price validation (Line 16)
    Super class doesn't validate price in constructor but subclasses do. Add initial validation in Product constructor.

Summary

Refine precision handling and edge cases throughout analytics methods, particularly with BigDecimal operations and edge value handling. Address the constructor mismatch to pass all tests.


Previous Feedback

🕒 Posted on 2025-10-23T13:32:13.599Z

Overall Feedback

Looks good to me! All requirements are met and tests pass successfully. The implementation is well-structured with proper encapsulation, polymorphism, and clean handling of edge cases.

What's Working Well

  • The Singleton pattern implementation for Warehouse is robust with thread-safe storage and proper product lifecycle management.
  • Business logic in WarehouseAnalyzer directly addresses complex requirements like weighted averages, statistical outlier detection, and shipping optimization.
  • Error handling consistently follows test expectations (null checks, negative value validation).

Areas for Improvement

  • Comment Precision (WarehouseAnalyzer.findPriceOutliers):
    The comment states "Uses population standard deviation" but uses IQR instead. Consider updating to:

    // Uses IQR method with multiplier over all products  

    Explanation: The test expects IQR-based outlier detection (2.0 multiplier), but the description conflicted with implementation.

  • Quartile Interpolation Edge Case (WarehouseAnalyzer.getQuartile):
    When fraction=0, returns exact index value. Simplify by merging conditions:

    BigDecimal interpolatedValue = lowerIndex >= n - 1 ?  // Handle edge case directly  
        upperValue : lowerValue.add(diff.multiply(BigDecimal.valueOf(fraction)));  

    Explanation: Current method handles fraction=0 but unnecessarily checks lowerIndex >= n-1 in multiple conditions.

Summary

Excellent job on meeting core requirements and advanced functionality. The key takeaway: Ensure documentation always matches implementation logic to avoid confusion.


Previous Feedback

🕒 Posted on 2025-10-20T12:28:44.822Z

Overall Feedback

Looks good! The WarehouseAnalyzer implementation satisfies all test requirements in EdgeCaseTest. The solution is comprehensive, well-structured, and follows Java conventions appropriately.

What's Working Well

  • Boundary handling in findProductsInPriceRange correctly includes exclusion boundaries
  • Polymorphic behavior in getInventoryStatistics correctly handles Perishable and non-perishable products for expiration tracking
  • Weighted average calculation accounts for both shippable (weight > 0) and non-shippable products
  • Currency rounding consistently uses HALF_UP rounding mode as required
  • Optimal Test Coverage addresses all advanced requirements through precise implementations

Areas for Improvement

  • Precision Handling: When calculating weighted averages, multiply price by weight as BigDecimal before conversion to double to prevent floating-point precision issues (though functional for test values)
  • Shipping Optimization: Consider more efficient grouping algorithms if performance becomes critical, though first-fit decreasing satisfies requirements
  • NullPointerException Handling: In validateInventoryConstraints, edge case occurs when warehouse contains exactly 0 products

Summary

The solution is complete and meets all requirements. The most important takeaway is careful edge case handling in calculations involving floating-point values and null safety.


Previous Feedback

🕒 Posted on 2025-10-06T06:42:56.745Z

Overall Feedback

Excellent work! Your WarehouseAnalyzer implementation is comprehensive and handles all the advanced requirements correctly. The code is well-structured, follows Java conventions, and demonstrates a strong understanding of the domain logic. All edge cases and business rules are properly implemented. LGTM!


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.

3 participants