This project serves as a hands-on demonstration of Object-Oriented Programming (OOP) principles in Java, specifically utilizing interfaces to implement various filtering strategies. The core objective is to create distinct, reusable filtering logic that can be applied to different data types (Strings and Rectangles) via a common Filter interface.
This lab fulfills the following learning objectives:
- Demonstrate the creation and implementation of interfaces in Java.
- Apply the Strategy Pattern by allowing the main program to switch between filtering behaviors at runtime.
- Design and implement specific filtering logic for different data types.
- Understand the benefits of loose coupling and flexible code architecture.
| Interface Name | Description |
|---|---|
ShortWordFilter |
Implements the provided Filter interface to identify and filter out String objects that are below a defined minimum length. |
BigRectangleFilter |
Implements the provided Filter interface to identify and filter out Rectangle objects that exceed a defined size or area threshold. |
| Component | Responsibility |
|---|---|
Driver Program |
The main execution class. Responsible for instantiating the data sets (e.g., list of words, list of rectangles) and demonstrating the use of both the ShortWordFilter and BigRectangleFilter. |
Filter Interface |
(Provided) The base interface that defines the required method signature for all filtering strategies. |
The Driver program applies the custom filters sequentially:
- Creates a list of sample
Stringobjects. - Applies the
ShortWordFilter. - Prints the filtered list (only long words remain).
- Creates a list of sample
Rectangleobjects. - Applies the
BigRectangleFilter. - Prints the filtered list (only small/medium rectangles remain).
UML diagrams for all created interfaces and classes (ShortWordFilter, BigRectangleFilter, Driver class).
