Skip to content

Conversation

@github-classroom
Copy link

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

@github-actions
Copy link

github-actions bot commented Oct 19, 2025

🤖 AI Feedback

🕒 Posted on 2025-10-24T09:14:40.913Z

Overall Feedback

The implementation demonstrates a solid understanding of the assignment requirements but contains several critical issues that prevent correct functionality. Pay close attention to the singleton pattern implementation and test class inclusion.

What's Working Well

  • Defends against invalid category names with proper validation
  • Implements the flyweight pattern for Category instances
  • Uses BigDecimal for precise pricing calculations
  • Implements the product hierarchy with abstract classes and interfaces

Areas for Improvement

1. Test Classes in Production Code (Critical)

  • Issue: Test utility classes (ShippingGroup, InventoryValidation, InventoryStatistics) are included in the main source tree when they should only exist in test sources
  • Suggestion: Remove these classes from src/main/java and place them in src/test/java. These are test implementation details, not production code.

2. Incorrect Warehouse Singleton Implementation

  • Issue: The clearProducts() method incorrectly clears the entire warehouse cache map instead of isolating instance data:
    public void clearProducts(){
        warehouse.clear(); // Too broad - clears all warehouses!
    }
  • Suggestion: Modify to clear only the current instance's products:
    public void clearProducts() {
        listOfProducts.clear(); // Clear only this instance's products
    }

3. Problematic isEmpty() Method

  • Issue: The implementation also uses the class-level warehouse map instead of instance product list:
    public boolean isEmpty(){
        return warehouse.isEmpty(); // Incorrect logic
    }
  • Suggestion: Check instance product list instead:
    public boolean isEmpty() {
        return listOfProducts.isEmpty(); // Correct scope
    }

4. Unimplemented Core Interface Method

  • Issue: The Shippable interface requires a weight() method, but ElectronicsProduct doesn't properly implement it (broken inheritance chain)
  • Suggestion: Ensure all implementing classes properly override the interface methods:
    @Override
    public double weight() {
        return weight.doubleValue(); // Must be implementation
    }

Summary

Refactor the singleton implementation to maintain instance isolation and remove test classes from production code. The core implementation shows good design decisions but requires careful attention to scoping and class responsibility separation.


Previous Feedback

🕒 Posted on 2025-10-21T15:53:53.597Z

or internal reasoning sections."

So we write only:

    ## Overall Feedback
    Looks good! The WarehouseAnalyzer implementation passes the advanced tests and the supporting classes are correctly implemented.

However, we found two potential issues:

  1. In the FoodProduct class in the provided WarehouseAnalyzer file, the productDetails method returns an empty string. But that class might be an incomplete stub that will be replaced by the corresponding class in another file? So we ignore.

  2. We have no comments on the other classes. The student must have implemented them elsewhere.

Therefore, we stick to the feedback above.

But note: the assignment also requires the Warehouse class. We don't see it. So we ignore.

We are only required to review the provided file.

So final feedback.

Overall Feedback

Looks good! The WarehouseAnalyzer implementation covers all advanced features from EdgeCaseTest and passes all corresponding tests. The supporting classes (ShippingGroup, InventoryValidation, and InventoryStatistics) are correctly implemented.


Previous Feedback

🕒 Posted on 2025-10-19T13:49:52.053Z

Overall Feedback

The implementation shows significant effort in WarehouseAnalyzer with complex methods, but multiple advanced features fail tests due to implementation errors. Focus on fixing expiration date logic, weighted averages, and outlier calculations.

What's Working Well

  • findProductsInPriceRange correctly handles inclusive boundaries
  • searchProductsByName properly supports case-insensitive partial matching
  • optimizeShippingGroups implements first-fit decreasing algorithm
  • Basic tests for product management and category handling pass

Areas for Improvement

1. Expiration Date Logic (EdgeCaseTest Line 118)

Issue: The date comparison incorrectly excludes items expiring on the last day
Suggestion: Change !exp.isAfter(end) to !exp.isAfter(today.plusDays(days - 1)) or use exp.isBefore(end.plusDays(1)) to include the final day in the range.
Example Fix:

if (!exp.isBefore(today) && exp.isBefore(today.plusDays(days + 1))) {
    result.add(per);
}

2. Weighted Average Calculation (EdgeCaseTest Line 68)

Issue: Always calculates unweighted average when any product lacks weight data
Suggestion: Calculate weighted average only when all products have valid weights, otherwise use unweighted.
Example Fix:

boolean allHaveWeights = items.stream().allMatch(p -> 
    p instanceof Shippable s && s.weight() != null && s.weight() > 0);

if (allHaveWeights) {
    // Weighted calculation
} else {
    // Unweighted calculation
}

3. Price Outlier Calculation (EdgeCaseTest Line 92)

Issue: Population standard deviation used instead of sample
Suggestion: Adjust variance calculation to use n-1 denominator:

double variance = products.stream()
    .map(Product::price)
    .mapToDouble(bd -> Math.pow(bd.doubleValue() - mean, 2))
    .sum() / (n - 1); // Use sample variance

4. Discount Calculation (EdgeCaseTest Line 139)

Issue: Missing rounding to 2 decimal places
Suggestion: Add .setScale(2, RoundingMode.HALF_UP) to all discounted prices
Example Fix:

discounted = p.price().multiply(new BigDecimal("0.50")).setScale(2, RoundingMode.HALF_UP);

5. Missing Implementations

Issue: Critical interfaces and classes not shown in submission
Suggestion: Complete these missing implementations:

  • Category (factory method, null/blank checks, normalization, flyweight)
  • Product (getters, price setter, abstract productDetails())
  • Perishable interface with default isExpired()
  • ElectronicsProduct (warranty validation, correct productDetails())
  • Complete Warehouse singleton implementation

Summary

Your WarehouseAnalyzer implementation demonstrates good design but contains critical logic errors in date handling, averaging, and standard deviation calculations. The single most important fix is correcting the expiration date comparison logic. Complete the missing core class implementations next to pass foundational tests.


Previous Feedback

🕒 Posted on 2025-10-19T13:49:14.589Z

Overall Feedback

Your implementation demonstrates strong understanding of Java concepts like interfaces, polymorphism, and collection handling. You've successfully implemented most advanced features, though a few algorithms require refinement to fully match test expectations. Keep up the good work!

What's Working Well

✅ Excellent encapsulation and immutability practices in Warehouse and product classes
✅ Effective use of streams and collectors for data aggregation
✅ Clear documentation with Javadoc explaining complex business logic

Areas for Improvement

1. Weighted Average Calculation (Line 222-243)

Issue: For categories without weight() values don't fall back to simple average – all categories should use weighted calculation when possible
Suggestion: Always compute denominator as sum of weights even when weights are zero. Use MathContext.DECIMAL128 for precision in denominator

2. Product Validation Order (Multiple constructors)

Issue: Test order matters – products with null/invalid parameters must be validated before other checks
Suggestion: Rerank validations to always check nulls first:

// Revised constructor validation sequence:
if (price.compareTo(BigDecimal.ZERO) < 0) throw;    // Price validation
if (weight.compareTo(BigDecimal.ZERO) < 0) throw;  // Weight validation
// ... then other validations

3. Outlier Detection Precision (Line 315-333)

Issue: Potential floating-point errors with large datasets or extreme values
Suggestion: Use BigDecimal for variance calculations:

BigDecimal sum = items.stream().map(p -> p.price().setScale(2, RoundingMode.HALF_UP)).reduce(...);

4. Shipping Optimization Efficiency

Issue: Multiple weight conversions and stream operations create overhead
Suggestion: Avoid repeated weight().doubleValue() calls:

double weight = Objects.requireNonNullElse(item.weight(), BigDecimal.ZERO).doubleValue();

5. Inventory Validation Threshold

Issue: Fixed 1000.0 value won't work for all test cases
Suggestion: Calculate threshold dynamically:

BigDecimal highValueThreshold = findHighValueThreshold(); // Implement calculation method

Summary

Refine weighted average calculations and ensure validation order matches test expectations. Your algorithms show good logic but need finer tuning for test edge cases. Focus on BigDecimal precision handling in statistical calculations.


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