Purpose Of Assignment: The University Needs To Develop An

Purpose Of Assignmentthe University Has A Need To Develop An Object Or

The assignment involves creating an object-oriented parking system for a university. The system requires classes for parking lots, parking office, money, and car types, with specific attributes and behaviors tailored to manage parking transactions, customer registration, and parking fees. Implementation must utilize Java Generics, Collections, and Enums. The parking lots have different rates, and a discount applies to compact cars. The parking office sends monthly bills, but payment is outside the system. The project also requires developing class diagrams, source code, and unit tests, along with a comprehensive write-up explaining design choices, challenges, and implementation details.

Paper For Above instruction

Designing and implementing a parking system for a university environment posed an interesting challenge that required careful consideration of object-oriented principles and Java programming features. The core classes—ParkingOffice, ParkingLot, Money, and the enum CarType—were designed to encapsulate relevant data and behaviors, facilitating modular, maintainable, and extendable code. Throughout the development process, understanding how to effectively leverage Java Collections, Generics, and Enums was critical, and this significantly influenced the architecture and functionality of the system.

One of the initial difficulties faced was determining how to model the complex relationships between customers, parking permits, and parking lots. Since the task emphasizes the use of collections, I used Java Lists to manage multiple customers and parking lots within the ParkingOffice class efficiently. Collections provided a flexible way to add, remove, and iterate over these objects, enabling scalability as the system matured. Java Generics were used extensively; for example, the list of customers and parking lots was declared as List and List, ensuring type safety and reducing runtime errors.

Choosing to implement the Money class as immutable was strategic. Immutable classes provide thread-safety and require less concern about unintended side effects. I implemented the Money class with final fields and no setters, allowing values to be set only at object creation. This ensures the integrity of monetary data, which is crucial for financial calculations like parking fees. The class included methods to retrieve amounts and currency but did not allow modification once instantiated.

The CarType enum was straightforward but essential in simplifying logic, especially regarding discounts. By defining specific enum values, such as COMPACT and SUV, the system could easily assign parking rates and apply discounts. For example, a 20% discount was applied to compact cars using a method that checked the CarType and calculated the rate accordingly. Enums also improved code readability and reduced errors associated with string literals.

In terms of implementation decisions, I chose to make the ParkingLot class immutable, with final fields for ID, name, and address. This ensured that once a parking lot was created, its core attributes remained consistent. The getDailyRate(CarType) method dynamically returned the appropriate rate based on the car type, incorporating the discount where applicable. For the Address class, I used a simple composition pattern, assuming it was a value object with standard attributes like street, city, and postal code.

Throughout development, using Java’s built-in Enum and Collection frameworks simplified handling of data and behaviors. I tested the system's functionalities by creating instances of parking lots, adding them to the ParkingOffice, and simulating parking fee calculations for different car types. The program compiled without errors, and tests confirmed accurate fee computations and correct class behaviors. This experience highlighted the importance of clean design, immutability, and type safety.

In conclusion, the project was a valuable exercise in applying core object-oriented design principles using Java. The experience of making classes immutable, effectively using Generics and Collections, and leveraging Enums enhanced my understanding of building scalable systems. The challenges encountered, such as modeling relationships and ensuring data integrity, emphasized the importance of thoughtful class design. If I were to approach this project again, I would explore incorporating design patterns like Factory or Builder to further improve flexibility and clarity.

References

  • Bloch, Joshua. 2018. Effective Java. 3rd ed. Boston: Addison-Wesley.
  • Gamma, Erich, Richard Helm, Ralph Johnson, and John Vlissides. 1994. Design Patterns: Elements of Reusable Object-Oriented Software. Boston: Addison-Wesley.
  • Oracle Corporation. 2023. Java Platform, Standard Edition Documentation. https://docs.oracle.com/en/java/javase/17/docs/api/.
  • Deitel, Paul J., and Harvey Deitel. 2017. Java How to Program. 10th ed. Pearson Education.
  • Horstmann, Cay S. 2020. Core Java Volume I--Fundamentals. 11th ed. Pearson.