A Java application that analyzes relationships between rectangles, including containment, adjacency classification, and intersection detection.
- Java 21
- Maven 3.9+ (or use the maven wrapper)
sudo apt update
sudo apt install -y openjdk-21-jdk
export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64To persist JAVA_HOME across sessions:
echo 'export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64' >> ~/.bashrc
source ~/.bashrcNote: The path to the JDK will vary from architecture to architecture
- Determine whether one rectangle contains another
- Classify adjacency between rectangles (PROPER, PARTIAL, SUBLINE, NONE)
- Compute intersection region for overlapping rectangles
- Rectangles are defined by two points with non-zero width and height
- Containment is inclusive (identical rectangles are considered contained)
- Adjacency requires a shared boundary with positive length
- Intersection is defined as the overlapping area between two rectangles. The four returned points are the corners of that overlap region. Shared edges or corners alone are not considered intersections.
The following image depicts a rectangle defined by two points (1, 1) and (3, 4)
./mvnw test./mvnw package./mvnw package -DskipTests
java -cp target/rectangle-1.0-SNAPSHOT.jar com.ty.MainBuild and run using Docker:
docker build -t rectangle .
docker run rectangleRun tests and generate a Jacoco coverage report
./mvnw testOpen the report in a browser at the following location
target/site/jacoco/index.html



