Java Video Rental System Project
Java Video Rental System Project
Encapsulation enhances the design by restricting direct access to video attributes; it provides public methods like getTitle(), checkOut(), and returnVideo() for controlled manipulation, ensuring data integrity and reducing errors from unauthorized access.
Improvements could include dynamic inventory management using data structures like ArrayList for flexible size adjustment, implementing persistent storage for data retrieval after restarts, and adding user management capabilities to handle multiple customers and transactions for scalability and improved business operations.
Aggregation plays a crucial role as the VideoStore class contains an array of Video objects. This signifies a whole-part relationship, allowing VideoStore to manage and access each individual Video, which streamlines operations like adding, rating, and checking out videos, thus ensuring organized interaction with the inventory.
The system handles errors by checking conditions before making state changes, such as whether inventory is full before adding new videos, or whether a video is already checked out before proceeding. Error messages are displayed when constraints are violated. While this provides feedback, the lack of dynamic inventory scaling and more detailed error handling limits effectiveness.
The concept of a 'class' is implemented through the Video class which encapsulates properties such as title, checkedOut status, and averageRating. It includes methods for checking out, returning, and rating the video, encapsulating the data and behaviors related to video items within one unit.
Average ratings are calculated using a cumulative average formula. When a new rating is received, it updates the averageRating by multiplying the current average by the number of ratings, adding the new rating, and dividing by the incremented number of ratings. This maintains an accurate running average.
The system uses a boolean field `checkedOut` in the Video class, toggled by checkOut() and returnVideo() methods, to manage the checked-out status. This approach ensures that videos cannot be checked out multiple times or returned without being checked out first, improving user experience by maintaining accurate transactional records.
The system ensures integrity and accuracy by updating average ratings through a formula that considers previous ratings and the number of times the video has been rated. Methods enforce structured access to modify ratings, preventing direct and erroneous manipulations, and ensure correct calculations are followed.
The primary objectives are to learn about classes, encapsulation, and the aggregation concept in Java.
The system limits inventory to 10 videos, potentially leading to issues where new entries cannot be added if all slots are filled, as indicated by error messages. This constraint may prevent the store’s inventory from scaling with business growth, affecting service delivery and customer satisfaction.