Portobello Manager is a Java CLI (Command Line Interface) application designed to manage a second-hand store inventory. The system allows users to organize items into a hierarchical structure (categories containing products or sub-categories), calculate the total value of the inventory, and export the full catalog to a text file.
This project was developed as a final assignment to demonstrate proficiency in Object-Oriented Programming, Design Patterns, and core Java technologies.
- Hierarchical Organization: Create products and nest them inside categories and sub-categories.
- Total Calculation: Automatically calculate the total price of any category (recursive).
- Input Validation: Prevents invalid data (e.g., negative prices) using custom exceptions.
- Data Export: Saves the entire catalog structure into a flat file (
export_catalogo.txt).
The architecture is based on specific Design Patterns to ensure maintainability and scalability:
- Composite Pattern (
CatalogIteminterface,Product,Category):- Reason: Used to treat individual objects (Products) and compositions of objects (Categories) uniformly. This allows infinite nesting of categories.
- Factory Pattern (
CatalogFactory):- Reason: Centralizes object creation logic. It keeps the Main class clean and separates the instantiation logic from the business logic.
- Iterator Pattern (
StoreIterator):- Reason: Implemented to traverse the complex tree structure (categories inside categories) as a flat list. This is essential for printing the full list or exporting it to a file line-by-line.
- Exception Shielding (
CatalogException):- Reason: Custom checked exception used to handle specific domain errors (like negative prices) without crashing the application or showing raw stack traces to the user.
- Java SE 21: Core language.
- Maven: Dependency management and build automation.
- SLF4J / Logback: Professional logging framework (replacing System.out).
- JUnit 5: Unit testing framework.
- Java I/O: For writing reports to disk.
To run this project, you need JDK 21 and Maven installed.
-
Build the project:
mvn clean install
-
Run Tests:
mvn test -
Run the Application: You can run the
Mainclass directly from your IDE (IntelliJ/Eclipse) or use the command line. Upon execution, the program will:- Create a sample dataset in memory.
- Print the structure and total value to the console logs.
- Generate a file named
export_catalogo.txtin the project root.
- Data Persistence: Currently, data is stored in memory and lost when the application closes. Future implementation could include a Database connection.
- User Interface: The interaction is currently hardcoded in the Main class for demonstration purposes. A future update could add an interactive CLI menu or a GUI.
Placeholder