Practice/Amazon/Design a Vehicle Renting System
Design a Vehicle Renting System
Object Oriented DesignMust
Problem
Design and implement a Hotel Room Booking System that manages room inventory, handles reservations, and processes guest checkouts. The system must support various room categories, implement flexible pricing mechanisms, track room availability across date ranges, and prevent double bookings.
Your implementation should handle the complete lifecycle of a hotel booking: from searching for available rooms based on criteria, creating reservations for specific date ranges, calculating costs based on pricing strategies, and processing checkouts that return rooms to the available inventory.
Requirements
- Room Management: Support multiple room types (standard, deluxe, suite) with different base prices and track individual room status
- Availability Search: Find available rooms of a specific type for a given date range, ensuring no booking conflicts
- Booking Creation: Reserve a room for a specified check-in and check-out period, generating a unique booking identifier
- Pricing Strategy: Implement flexible pricing calculation that can apply different strategies (flat rate, peak season multipliers, discounts)
- Checkout Process: Release rooms back to available inventory when guests check out
- Cost Calculation: Compute total booking cost based on number of nights and applicable pricing strategy
- Conflict Prevention: Ensure a room cannot be double-booked for overlapping date ranges
Constraints
- Room IDs and booking IDs must be unique within the system
- Check-out date must be after check-in date
- A room can only have one active booking for any given date
- Base prices must be positive numbers
- System should handle at least 100 rooms efficiently
- Date comparisons should be accurate to the day level
Examples
Example 1: Basic Booking Flow
`
System Setup:
- Add Room: ID="R101", Type=STANDARD, BasePrice=100
Operations:
- Book room R101 from Jan 1 to Jan 4 (3 nights)
- Calculate cost → 100 × 3 = 300
- Checkout booking
- Room R101 becomes available again
Output: Booking successful, total cost 300, checkout successful
`
Example 2: Availability Search with Conflicts
`
System Setup:
- Add Room: ID="R101", Type=STANDARD, BasePrice=100
- Add Room: ID="R102", Type=STANDARD, BasePrice=100
- Add Room: ID="S201", Type=SUITE, BasePrice=250
Operations:
- Book R101 from Jan 1 to Jan 5
- Book R102 from Jan 3 to Jan 7
- Search for available STANDARD rooms from Jan 2 to Jan 6
Output: No available rooms (R101 conflicts on Jan 2-4, R102 conflicts on Jan 3-6)
`
Example 3: Dynamic Pricing
`
System Setup:
- Add Room: ID="R101", Type=DELUXE, BasePrice=150
- Apply PeakSeasonPricing with 1.5x multiplier
Operations:
- Book R101 for 4 nights during peak season
- Calculate cost → 150 × 1.5 × 4 = 900
Output: Total cost 900
`