This project implements a collection of geometric shapes with functionalities to determine intersections between them. It includes comprehensive test cases using JUnit to validate the intersection methods and robust exception handling to manage invalid shape constructions.
- Circle Intersections: Methods to check intersections between circles and other shapes.
- Rectangle Intersections: Methods to check intersections between rectangles and other shapes.
- Line Segment Intersections: Methods to check intersections between line segments and other shapes.
- Point Intersections: Methods to check intersections involving points.
- Comprehensive Test Cases: Designed to cover various intersection scenarios to identify potential bugs.
- Automated Testing: Implemented using JUnit to ensure reliability and correctness of intersection methods.
- Test Documentation: All test cases are documented in
A2Test.pdf
, detailing expected results, actual results, and test outcomes.
- Custom Exception: Defined
ShapeArgumentException
to handle invalid shape constructions. - Validation Checks:
- Line segments with coincided begin and end points.
- Circles with non-positive radii.
- Rectangles with invalid dimensions (left >= right or bottom >= top).
- Error Reporting: Exceptions are caught and an appropriate message is printed, indicating the shape class where the error occurred.
-
Test Documentation
A2Test.pdf
: Detailed report of all designed test cases, including expected results, actual results, and pass/fail status.
-
JUnit Tests
A2Test.java
: Implementation of all JUnit test cases organized by intersection methods.
-
Source Code with Exception Handling
AbstractShape.java
: Base class for all shapes with common properties and methods.CollisionDetector.java
: Utility class containing methods to detect collisions between different shapes.Circle.java
: Implementation of the Circle shape with intersection methods and validation.Rectangle.java
: Implementation of the Rectangle shape with intersection methods and validation.LineSeg.java
: Implementation of the Line Segment shape with intersection methods and validation.Point.java
: Implementation of the Point class representing coordinates in 2D space.ShapeArgumentException.java
: Custom exception class for handling invalid shape arguments.
- Setup: Ensure that JUnit is installed and configured in your development environment.
- Execute Tests: Run the
A2Test.java
file using your IDE's JUnit test runner or via the command line. - Review Results: Check the console output and the
A2Test.pdf
document to review the outcomes of each test case.
- When constructing shapes, invalid parameters will trigger a
ShapeArgumentException
. - The exception message will indicate the type of shape that failed to construct, aiding in debugging and ensuring robust usage of the shape classes.
- Clone the Repository
git clone https://github.com/yourusername/shape-intersection-project.git
- Navigate to the Project Directory
cd shape-intersection-project
- Explore the Source Code and Test Cases
- Review the implementation of shape classes and intersection methods.
- Examine the JUnit test cases to understand the scenarios covered.
- Run the JUnit Tests
- Use your preferred method to execute A2Test.java with JUnit.