A collection of Object-Oriented Programming (OOP) laboratory assignments developed during Computer Engineering studies at Politecnico di Torino.
This repository showcases progressive learning in Java OOP principles, design patterns, and modern Java frameworks. Each lab builds upon previous concepts, gradually introducing more complex design patterns and technologies.
The Weather Report System is a comprehensive environmental monitoring data management application developed as a group project for the Object-Oriented Programming course. The system manages environmental monitoring data collected from an infrastructure composed of networks, gateways, and sensors, providing capabilities for data storage, configuration management, statistical analysis, and real-time anomaly detection.
- Networks: Logical groupings of monitoring infrastructure with operator management
- Gateways: Device groups monitoring physical quantities with configurable parameters
- Sensors: Individual measurement devices with threshold-based anomaly detection
- Complete CRUD operations with audit trails (creation/modification tracking)
- ORM Framework: Hibernate (JPA) for object-relational mapping
- Database: H2 in-memory relational database
- Repository Pattern: Generic
CRUDRepositoryand specializedMeasurementRepository - Entity relationship management with proper foreign key constraints
- Statistical Analysis: Mean, variance, standard deviation calculations
- Outlier Detection: 2-sigma rule implementation for anomaly identification
- Histogram Generation: Temporal distributions (hourly/daily) and value distributions
- Activity Metrics: Most/least active gateways and sensors
- Load Analysis: Resource distribution ratios and percentages
- Multi-level reports: Network, Gateway, and Sensor level reporting
- Threshold Violation Detection: Automatic detection of sensor value anomalies
- Notification System: Alert operators when thresholds are exceeded
- CSV Data Import: Bulk measurement ingestion from CSV files
- Time-Series Processing: Efficient handling of temporal data with interval-based queries
- Facade Pattern:
WeatherReportclass as unified system entry point - Factory Pattern:
OperationsFactoryfor operations instantiation - Repository Pattern: Data access abstraction layer
- Layered Architecture: Clear separation between model, operations, repositories, services, and reports
- Role-Based Access Control: VIEWER (read-only) and MAINTAINER (read/write) roles
- Custom Exception Hierarchy: Comprehensive error handling
- Input Validation: Format validation, unique identifier constraints, entity existence checks
- Authorization Checks: Permission-based operation execution
Operations Layer:
NetworkOperations: Network and operator management with network-level reportingGatewayOperations: Gateway and parameter configuration with gateway-level reportingSensorOperations: Sensor and threshold management with sensor-level reportingTopologyOperations: Hierarchical relationship management (network ↔ gateway ↔ sensor)
Data Layer:
- Generic
CRUDRepository<T, ID>for reusable data access patterns - Specialized
MeasurementRepositoryfor time-series measurement queries - JPA entity mappings with proper relationships and cascading
Service Layer:
DataImportingService: CSV parsing and measurement storageAlertingService: Threshold violation notifications and deletion notifications
Reporting Layer:
NetworkReport: Aggregated network statistics with temporal histogramsGatewayReport: Gateway metrics with inter-arrival time analysisSensorReport: Sensor-level statistics with value distribution histograms
T116-weather-report/
├── src/main/java/com/weather/report/
│ ├── model/entities/ # Domain entities (Network, Gateway, Sensor, etc.)
│ ├── operations/ # Operation interfaces and implementations
│ ├── repositories/ # Data access layer
│ ├── services/ # Business services (import, alerting)
│ ├── reports/ # Report generation implementations
│ └── utils/ # Utility classes (DateUtils, RangeImpl)
├── src/main/resources/
│ ├── csv/ # Sample measurement data files
│ └── META-INF/
│ └── persistence.xml # JPA configuration
└── src/test/ # Comprehensive test suites
- GitFlow Workflow: Feature branches with mandatory code reviews
- Test-Driven Development: JUnit 5 and Mockito for unit testing
- Code Quality: SOLID principles, clean code architecture
- Collaborative Development: Team-based implementation with merge requests
- Documentation: Comprehensive inline documentation and README
The project was developed in four phases:
- R1 - Network Management: Network and operator CRUD, network-level reporting
- R2 - Gateway Management: Gateway and parameter management, gateway-level reporting
- R3 - Sensor Management: Sensor and threshold management, sensor-level reporting
- R4 - Topology Integration: Hierarchical relationship management and system integration
- Language: Java 25
- ORM: Hibernate 7.1.7 (JPA 3.2)
- Database: H2 2.4.240
- Build Tool: Maven
- Testing: JUnit 5, Mockito 5.20.0
- Logging: Log4j2
- Version Control: Git with GitFlow
- 137+ Java Classes: Comprehensive implementation across all layers
- Statistical Algorithms: Implemented mathematical formulas for variance, standard deviation, and outlier detection
- Time-Series Analysis: Efficient temporal data processing with histogram generation
- Design Patterns: Factory, Repository, Facade, Strategy patterns
- Database Design: Normalized relational schema with proper relationships
The complete Weather Report System implementation can be found in the T116-weather-report/ directory. For detailed technical documentation, see T116-weather-report/README.md.
| Category | Technology |
|---|---|
| Language | Java (JDK 25) |
| Paradigm | Object-Oriented Programming (OOP) |
| Build Tool | Apache Maven |
| Testing Framework | JUnit 5 |
| Persistence | Hibernate ORM, JPA (Jakarta Persistence API) |
| Database | H2 (in-memory) |
| Version Control | Git (GitHub, GitLab) |
Objective: Introduction to Java fundamentals and basic project structure.
Description: A command-line calculator that performs basic arithmetic operations (addition, subtraction, multiplication, division) with proper input/output handling and error management.
Key Concepts:
- Java syntax and basic language features
- Class design and method implementation
- Console I/O operations (
System.in,System.out) - Exception handling
- Maven project structure
- Unit testing with JUnit
Files Structure:
Calculator.java: Core calculator logicIO.java: Input/Output utility classTestCalculator.java: Unit tests
Objective: Design and implement an object-oriented system managing university entities and their relationships.
Description: A complete university management system that handles students, courses, registrations, exams, and generates various statistics and reports.
Key Concepts:
- Class design and encapsulation
- Collections (
Map,Set,List) - Relationships between entities
- Data aggregation and reporting
- Iterator pattern
- Logging framework integration
Features Implemented:
- Student enrollment and management
- Course activation and management
- Student-course registration
- Exam recording and grading
- Average calculations (student and course)
- Top student rankings
- Award system
Files Structure:
University.java: Main facade class with all business logic- Test suites covering requirements R1-R7
Objective: Model complex interconnected systems using inheritance and polymorphism.
Description: A simulation system for hydraulic networks composed of various interconnected components (sources, taps, splits, sinks, multisplits) with flow propagation and observation capabilities.
Key Concepts:
- Inheritance hierarchies
- Polymorphism and method overriding
- Abstract classes and interfaces
- Observer pattern (
SimulationObserver) - Composite pattern (element connections)
- Builder pattern (
HBuilder) - Flow propagation algorithms
Components:
- Elements:
Source,Tap,Split,Multisplit,Sink - System:
HSystemmanages the network - Observers: Track simulation events
- Builder: Fluent API for system construction
Advanced Features:
- Multisplit elements with multiple outputs
- Flow control (tap open/close)
- Element deletion and reconnection
- Maximum flow calculations
Files Structure:
- Element hierarchy in
hydraulic/package HSystem.java: System managementHBuilder.java: Builder pattern implementation- Test suites covering requirements R1-R8
Objective: Design flexible systems using interfaces and composition for complex business logic.
Description: A comprehensive diet and nutrition management system handling raw materials, products, recipes, menus, restaurants, customers, and orders with nutritional information tracking.
Key Concepts:
- Interface-based design (
NutritionalElement) - Composition over inheritance
- Complex object relationships
- Data validation and constraints
- Business logic implementation
- Collection operations and filtering
Features Implemented:
- Raw materials and product management
- Recipe creation with nutritional calculations
- Menu composition (recipes + products)
- Restaurant and takeaway management
- Customer registration and profiles
- Order processing with dietary restrictions
- Nutritional information queries
- Branch management for restaurants
Architecture:
- Interfaces:
NutritionalElement(common interface for foods, recipes, menus) - Composition: Recipes contain raw materials, Menus contain recipes/products
- Relationships: Restaurants have branches, Orders link customers to restaurants
Files Structure:
- Domain models in
diet/package - Test suites covering requirements R1-R8
Objective: Work with external data sources and functional programming patterns.
Description: An information system for managing mountain huts and municipalities data loaded from CSV files, with query capabilities using Java Streams API.
Key Concepts:
- Stream API and functional programming
- Data loading from external sources (CSV)
- Filtering, mapping, and reduction operations
- Grouping and aggregation
- Lambda expressions and method references
- Optional type handling
- Complex queries and data transformations
Data Model:
- Region: Contains municipalities
- Municipality: Contains mountain huts, has altitude range
- MountainHut: Has name, category, beds, altitude
Features Implemented:
- CSV data parsing and loading
- Altitude range queries
- Hut filtering by various criteria
- Municipality and region statistics
- Advanced queries with grouping and aggregation
Files Structure:
- Domain models:
Region.java,Municipality.java,MountainHut.java - CSV data file:
mountain_huts.csv - Test suites covering requirements R1-R4
Objective: Implement persistent applications using Object-Relational Mapping (ORM) and database technologies.
Description: A full-featured social network application with user management, friendships, groups, and posts, all persisted using Hibernate ORM and JPA.
Key Concepts:
- JPA (Jakarta Persistence API) and Hibernate ORM
- Entity relationships (Many-to-Many, One-to-Many)
- Repository pattern
- JPQL (Java Persistence Query Language)
- Bidirectional relationships
- Pagination
- Transaction management
- Database schema generation
Features Implemented:
- User registration with unique codes
- User information retrieval
- Exception handling (
PersonExistsException,NoSuchCodeException)
- Bidirectional Many-to-Many friendships
- Friend list retrieval
- Automatic relationship synchronization
- Group creation and management
- Member subscriptions (Many-to-Many)
- Group renaming (with member preservation)
- Group deletion with cascade
- Person with largest number of friends
- Largest group by member count
- Person in most groups
- Post creation with unique alphanumeric IDs
- Timestamp tracking
- Paginated user posts (sorted by timestamp)
- Paginated friend posts feed
- Post content and metadata retrieval
Technical Implementation:
- Entities:
Person,Group,Postwith JPA annotations - Repositories:
PersonRepository,GroupRepository,PostRepositoryextendingGenericRepository - Relationships:
@ManyToManyfor friendships and group memberships - Queries: JPQL for complex queries with pagination
- Database: H2 in-memory database for testing
Files Structure:
src/social/
├── Person.java # User entity with friends relationship
├── Group.java # Group entity with members
├── Post.java # Post entity with author, content, timestamp
├── Social.java # Facade class with business logic
├── PersonRepository.java # Person data access
├── GroupRepository.java # Group data access
├── PostRepository.java # Post data access
├── GenericRepository.java # Generic CRUD operations
└── JPAUtil.java # EntityManager utility
Test Results: All 31 tests passing
This series of labs demonstrates progressive skill development:
- Lab 0: Java basics and tooling
- Lab 1: OOP fundamentals (classes, collections, relationships)
- Lab 2: Advanced OOP (inheritance, polymorphism, design patterns)
- Lab 3: Interface-based design and complex compositions
- Lab 4: Functional programming and stream processing
- Lab 5: Persistence and database integration
- Lab 6: Data management and statistics
- Java Development Kit (JDK) 25 or higher
- Apache Maven 3.6+
- Git
Each lab is a standalone Maven project. To run tests:
cd lab<number>-<name>
mvn clean testmvn clean compile- All labs follow the test-driven development approach with provided test suites
- Code adheres to clean code principles and SOLID principles
- Each lab builds upon concepts learned in previous labs
- Test suites are provided by the course instructors and validate correctness
Educational projects developed for academic purposes at Politecnico di Torino.
Developed as part of Object-Oriented Programming course at Politecnico di Torino.
Objective: Implement a clinic management system with patient and doctor management, assignments, and statistics.
Description: A system to manage patients and doctors in a medical clinic, with patient-doctor assignments, data loading from files, and various statistical queries.
Key Concepts:
- Data structures and collections
- File I/O operations
- Exception handling
- Data aggregation and statistics
- String formatting
Features Implemented:
- Patient and doctor management
- Patient-doctor assignment system
- File-based data loading with error handling
- Statistics: idle doctors, busy doctors, patient counts per doctor and specialization
Files Structure:
Clinic.java: Main facade class with all business logicErrorListener.java: Interface for error notifications- Exception classes:
NoSuchPatient,NoSuchDoctor - Test suite covering requirements R1-R5
Repository Status: ✅ All labs completed and tested