Skip to content

panta3/Java-Shape-GUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Shape Intersection Project

Overview

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.

Features

1. Intersection Methods

  • 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.

2. Testing with JUnit

  • 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.

3. Exception Handling

  • 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.

Project Structure

  • 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.

Usage

Running JUnit Tests

  1. Setup: Ensure that JUnit is installed and configured in your development environment.
  2. Execute Tests: Run the A2Test.java file using your IDE's JUnit test runner or via the command line.
  3. Review Results: Check the console output and the A2Test.pdf document to review the outcomes of each test case.

Handling Exceptions

  • 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.

Getting Started

  1. Clone the Repository
    git clone https://github.com/yourusername/shape-intersection-project.git
  2. Navigate to the Project Directory
    cd shape-intersection-project
  3. 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.
  4. Run the JUnit Tests
    • Use your preferred method to execute A2Test.java with JUnit.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages