Skip to content

Add L-shaped room support to paint calculator#24

Open
durimkryeziu wants to merge 1 commit into
mainfrom
feature/paint-calculator-l-shaped-room
Open

Add L-shaped room support to paint calculator#24
durimkryeziu wants to merge 1 commit into
mainfrom
feature/paint-calculator-l-shaped-room

Conversation

@durimkryeziu
Copy link
Copy Markdown
Owner

@durimkryeziu durimkryeziu commented May 24, 2026

Models an L-shaped room as an outer rectangle with a rectangular cut-out removed from one corner. Area = outer.area() minus cutout.area(). The cut-out must be strictly smaller than the outer rectangle on both length and width; equal dimensions are also rejected.

PaintCalculator gains a "3) L-shaped" menu option with four sequential prompts (outer length/width, cut-out length/width). The invalid-shape error is updated from "Please enter 1 or 2" to "Please enter 1, 2 or 3".

Summary by CodeRabbit

Release Notes

  • New Features
    • Paint calculator now supports L-shaped rooms in addition to rectangular and round options. Users can input outer rectangle dimensions and cutout dimensions to accurately estimate paint needed for L-shaped room configurations.

Review Change Stack

Models an L-shaped room as an outer rectangle with a rectangular
cut-out removed from one corner. Area = outer.area() minus
cutout.area(). The cut-out must be strictly smaller than the
outer rectangle on both length and width; equal dimensions are
also rejected.

PaintCalculator gains a "3) L-shaped" menu option with four
sequential prompts (outer length/width, cut-out length/width).
The invalid-shape error is updated from "Please enter 1 or 2"
to "Please enter 1, 2 or 3".
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 496498b1-0d76-497c-9789-96e5bb95dc60

📥 Commits

Reviewing files that changed from the base of the PR and between 69fc874 and e4f0e8e.

📒 Files selected for processing (5)
  • paint-calculator/src/main/java/dev/delivercraft/paint/LShapedRoom.java
  • paint-calculator/src/main/java/dev/delivercraft/paint/PaintCalculator.java
  • paint-calculator/src/main/java/dev/delivercraft/paint/RoomDimensions.java
  • paint-calculator/src/test/java/dev/delivercraft/paint/LShapedRoomTest.java
  • paint-calculator/src/test/java/dev/delivercraft/paint/PaintCalculatorTest.java

📝 Walkthrough

Walkthrough

This PR adds L-shaped room support to a paint calculator by introducing a new LShapedRoom record that computes area as an outer rectangle minus a cutout rectangle, integrating it into the sealed RoomDimensions type hierarchy, wiring it into the calculator's user prompts and input flow, and validating the entire feature with unit and integration tests.

Changes

L-shaped room feature

Layer / File(s) Summary
L-shaped room contract and sealed interface
paint-calculator/src/main/java/dev/delivercraft/paint/LShapedRoom.java, paint-calculator/src/main/java/dev/delivercraft/paint/RoomDimensions.java
LShapedRoom record stores outer and cutout RectangularRoom instances with constructor validation ensuring cutout is strictly smaller on both dimensions, computes area as outer.area() minus cutout.area(), and is added to the sealed RoomDimensions permits clause.
PaintCalculator UI and input flow
paint-calculator/src/main/java/dev/delivercraft/paint/PaintCalculator.java
Shape menu prompt extended to "3) L-shaped", new dimension prompts for outer rectangle and cutout rectangle dimensions, shape switch case "3" routes to readLShapedDimensions() which reads four inputs and constructs an LShapedRoom from two RectangularRoom objects, and invalid-choice error updated to permit options 1, 2, or 3.
LShapedRoom unit tests
paint-calculator/src/test/java/dev/delivercraft/paint/LShapedRoomTest.java
Tests verify null-checks on outer and cutout, area calculation for integer and fractional dimensions, cutout validation (rejecting equal or larger cutouts with specific error message), and paint estimation including gallon ceiling rounding across single and multi-gallon scenarios.
PaintCalculator integration tests and refactoring
paint-calculator/src/test/java/dev/delivercraft/paint/PaintCalculatorTest.java
Adds L-shaped test cases validating correct area output and fail-fast invalid-input behavior, updates parameterized and null-shape tests to assert "Please enter 1, 2 or 3", refactors test constants to share VALID_WIDTH, and verifies dimension validation exception message.

🎯 2 (Simple) | ⏱️ ~12 minutes

A rabbit hops through painted halls,
Adding L's to rectangular walls!
🎨 Cutouts carved with validation strong,
Test cases run the whole day long 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding support for L-shaped rooms to the paint calculator application.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/paint-calculator-l-shaped-room

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.17%. Comparing base (69fc874) to head (e4f0e8e).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##               main      #24      +/-   ##
============================================
+ Coverage     78.33%   79.17%   +0.84%     
- Complexity      123      129       +6     
============================================
  Files            34       35       +1     
  Lines           420      437      +17     
  Branches         25       26       +1     
============================================
+ Hits            329      346      +17     
  Misses           84       84              
  Partials          7        7              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants