Skip to content

Commit aad9ce5

Browse files
committed
update readmes
1 parent c5d395b commit aad9ce5

7 files changed

Lines changed: 897 additions & 189 deletions

File tree

Lines changed: 97 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,99 @@
1-
# Designing a Concert Ticket Booking System
1+
# Concert Ticket Booking System (LLD)
2+
3+
## Problem Statement
4+
5+
Design and implement a Concert Ticket Booking System that allows users to book seats for concerts. The system should manage concert details, seat availability, and handle bookings with proper validation.
6+
7+
---
28

39
## Requirements
4-
1. The concert ticket booking system should allow users to view available concerts and their seating arrangements.
5-
2. Users should be able to search for concerts based on various criteria such as artist, venue, date, and time.
6-
3. Users should be able to select seats and purchase tickets for a specific concert.
7-
4. The system should handle concurrent booking requests to avoid double-booking of seats.
8-
5. The system should ensure fair booking opportunities for all users.
9-
6. The system should handle payment processing securely.
10-
7. The system should generate booking confirmations and send them to users via email or SMS.
11-
8. The system should provide a waiting list functionality for sold-out concerts.
12-
13-
## Classes, Interfaces and Enumerations
14-
1. The **Concert** class represents a concert event, with properties such as ID, artist, venue, date and time, and a list of seats.
15-
2. The **Seat** class represents a seat in a concert, with properties like ID, seat number, seat type, price, and status. It provides methods to book and release a seat.
16-
3. The **SeatType** enum represents the different types of seats available, such as regular, premium, and VIP.
17-
4. The **SeatStatus** enum represents the status of a seat, which can be available, booked, or reserved.
18-
5. The **Booking** class represents a booking made by a user for a specific concert and seats. It contains properties such as ID, user, concert, seats, total price, and status. It provides methods to confirm and cancel a booking.
19-
6. The **BookingStatus** enum represents the status of a booking, which can be pending, confirmed, or cancelled.
20-
7. The **User** class represents a user of the concert ticket booking system, with properties like ID, name, and email.
21-
8. The **ConcertTicketBookingSystem** class is the central component of the system. It follows the Singleton pattern to ensure a single instance of the system. It manages concerts, bookings, and provides methods to add concerts, search concerts, book tickets, and cancel bookings.
22-
9. The **SeatNotAvailableException** is a custom exception used to handle cases where a seat is not available for booking.
10+
11+
- **Concert Management:** The system manages concert details including name, date, venue, and available seats.
12+
- **Seat Management:** The system tracks different types of seats (VIP, STANDARD, ECONOMY) and their availability.
13+
- **Booking Management:** Users can book seats, and the system handles booking status (CONFIRMED, CANCELLED).
14+
- **User Management:** The system maintains user information for bookings.
15+
- **Validation:** The system prevents double bookings and handles seat availability checks.
16+
17+
---
18+
19+
## Core Entities
20+
21+
- **ConcertTicketBookingSystem:** Main class that manages concerts, bookings, and seat allocation.
22+
- **Concert:** Represents a concert with its details and seat management.
23+
- **Seat:** Represents a seat with its type, status, and booking information.
24+
- **User:** Represents a user who can book tickets.
25+
- **Booking:** Represents a booking with its status and associated details.
26+
- **SeatType:** Enum for different seat categories (VIP, STANDARD, ECONOMY).
27+
- **SeatStatus:** Enum for seat states (AVAILABLE, BOOKED).
28+
- **BookingStatus:** Enum for booking states (CONFIRMED, CANCELLED).
29+
30+
---
31+
32+
## Class Design
33+
34+
### 1. ConcertTicketBookingSystem
35+
- **Fields:** List<Concert> concerts, List<Booking> bookings
36+
- **Methods:** addConcert(), bookSeat(), cancelBooking(), getAvailableSeats(), etc.
37+
38+
### 2. Concert
39+
- **Fields:** String name, String date, String venue, List<Seat> seats
40+
- **Methods:** addSeat(), getAvailableSeats(), bookSeat(), etc.
41+
42+
### 3. Seat
43+
- **Fields:** String seatNumber, SeatType type, SeatStatus status, Booking booking
44+
- **Methods:** isAvailable(), book(), cancel(), etc.
45+
46+
### 4. User
47+
- **Fields:** String name, String email
48+
49+
### 5. Booking
50+
- **Fields:** String bookingId, User user, Concert concert, Seat seat, BookingStatus status
51+
- **Methods:** confirm(), cancel(), etc.
52+
53+
### 6. Enums
54+
- **SeatType:** VIP, STANDARD, ECONOMY
55+
- **SeatStatus:** AVAILABLE, BOOKED
56+
- **BookingStatus:** CONFIRMED, CANCELLED
57+
58+
---
59+
60+
## Example Usage
61+
62+
```java
63+
ConcertTicketBookingSystem system = new ConcertTicketBookingSystem();
64+
65+
// Add a concert
66+
Concert concert = system.addConcert("Rock Concert", "2024-12-31", "Stadium");
67+
68+
// Book a seat
69+
User user = new User("John Doe", "john@example.com");
70+
Booking booking = system.bookSeat(concert, "A1", user);
71+
72+
// Cancel booking
73+
system.cancelBooking(booking);
74+
```
75+
76+
---
77+
78+
## Demo
79+
80+
See `ConcertTicketBookingSystemDemo.java` for a sample usage and simulation of the booking system.
81+
82+
---
83+
84+
## Extending the Framework
85+
86+
- **Add payment processing:** Integrate payment gateway for ticket purchases
87+
- **Add waitlist functionality:** Handle seat waitlist when fully booked
88+
- **Add discount management:** Support for different pricing tiers and discounts
89+
- **Add notification system:** Send booking confirmations and updates
90+
91+
---
92+
93+
## Design Patterns Used
94+
95+
- **Singleton Pattern:** For managing the booking system instance
96+
- **Factory Pattern:** For creating different types of seats
97+
- **Observer Pattern:** For notifying users about booking status changes
98+
99+
---
Lines changed: 141 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,143 @@
1-
# Designing a Cricket Information System like CricInfo
1+
# Cricket Information System (LLD)
2+
3+
## Problem Statement
4+
5+
Design and implement a Cricket Information System similar to CricInfo that provides comprehensive information about cricket matches, teams, players, and live scores. The system should handle real-time updates, match statistics, and user interactions.
6+
7+
---
28

39
## Requirements
4-
1. The Cricinfo system should provide information about cricket matches, teams, players, and live scores.
5-
2. Users should be able to view the schedule of upcoming matches and the results of completed matches.
6-
3. The system should allow users to search for specific matches, teams, or players.
7-
4. Users should be able to view detailed information about a particular match, including the scorecard, commentary, and statistics.
8-
5. The system should support real-time updates of live scores and match information.
9-
6. The system should handle concurrent access to match data and ensure data consistency.
10-
7. The system should be scalable and able to handle a large volume of user requests.
11-
8. The system should be extensible to accommodate new features and enhancements in the future.
12-
13-
## Classes, Interfaces and Enumerations
14-
1. The **Match** class represents a cricket match, with properties such as ID, title, venue, start time, teams, status, and scorecard.
15-
2. The **Team** class represents a cricket team, with properties like ID, name, and a list of players.
16-
3. The **Player** class represents a cricket player, with properties such as ID, name, and role.
17-
4. The **Scorecard** class represents the scorecard of a match, containing team scores and a list of innings.
18-
5. The **Innings** class represents an innings in a match, with properties like ID, batting team, bowling team, and a list of overs.
19-
6. The **Over** class represents an over in an innings, containing a list of balls.
20-
7. The **Ball** class represents a ball bowled in an over, with properties such as ball number, bowler, batsman, and result.
21-
8. The **MatchStatus** enum represents the different statuses of a match, such as scheduled, in progress, completed, or abandoned.
22-
9. The **MatchService** class manages the matches in the system, providing methods to add, retrieve, and update match information. It follows the Singleton pattern to ensure a single instance of the service.
23-
10. The **ScorecardService** class manages the scorecards of matches, allowing the creation, retrieval, and update of scorecards and their associated data, such as innings and scores. It also follows the Singleton pattern.
24-
11. The **CricinfoSystem** class serves as the main entry point of the system, integrating the match and scorecard services and providing high-level methods for interacting with the system.
10+
11+
1. **Match Information Management:**
12+
- Store and manage cricket match details
13+
- Track match schedules and results
14+
- Support real-time score updates
15+
- Handle match status transitions
16+
17+
2. **Team and Player Management:**
18+
- Maintain team rosters and player information
19+
- Track player roles and statistics
20+
- Support team composition changes
21+
22+
3. **Scorecard Management:**
23+
- Record detailed match statistics
24+
- Track innings, overs, and ball-by-ball information
25+
- Maintain batting and bowling statistics
26+
27+
4. **Search and Retrieval:**
28+
- Search for matches, teams, and players
29+
- View detailed match information
30+
- Access historical data and statistics
31+
32+
5. **System Requirements:**
33+
- Handle concurrent access
34+
- Ensure data consistency
35+
- Support scalability
36+
- Allow for future extensions
37+
38+
---
39+
40+
## Core Entities
41+
42+
### 1. Match
43+
- **Fields:** String id, String title, String venue, Date startTime, Team team1, Team team2, MatchStatus status, Scorecard scorecard
44+
- **Methods:** updateStatus(), getScorecard(), getMatchDetails()
45+
46+
### 2. Team
47+
- **Fields:** String id, String name, List<Player> players
48+
- **Methods:** addPlayer(), removePlayer(), getTeamStats()
49+
50+
### 3. Player
51+
- **Fields:** String id, String name, String role
52+
- **Methods:** getPlayerStats(), updateRole()
53+
54+
### 4. Scorecard
55+
- **Fields:** Match match, List<Innings> innings
56+
- **Methods:** addInnings(), updateScore(), getMatchSummary()
57+
58+
### 5. Innings
59+
- **Fields:** String id, Team battingTeam, Team bowlingTeam, List<Over> overs
60+
- **Methods:** addOver(), getInningsSummary()
61+
62+
### 6. Over
63+
- **Fields:** int overNumber, List<Ball> balls
64+
- **Methods:** addBall(), getOverSummary()
65+
66+
### 7. Ball
67+
- **Fields:** int ballNumber, Player bowler, Player batsman, String result
68+
- **Methods:** recordResult(), getBallDetails()
69+
70+
### 8. MatchStatus (Enum)
71+
- **Values:** SCHEDULED, IN_PROGRESS, COMPLETED, ABANDONED
72+
73+
---
74+
75+
## Services
76+
77+
### 1. MatchService (Singleton)
78+
- **Methods:**
79+
- addMatch(Match match)
80+
- getMatch(String id)
81+
- updateMatchStatus(String id, MatchStatus status)
82+
- searchMatches(String query)
83+
84+
### 2. ScorecardService (Singleton)
85+
- **Methods:**
86+
- createScorecard(Match match)
87+
- updateScorecard(String matchId, Scorecard scorecard)
88+
- getScorecard(String matchId)
89+
- addInnings(String matchId, Innings innings)
90+
91+
### 3. CricinfoSystem
92+
- **Methods:**
93+
- getMatchDetails(String matchId)
94+
- getTeamDetails(String teamId)
95+
- getPlayerDetails(String playerId)
96+
- search(String query)
97+
98+
---
99+
100+
## Example Usage
101+
102+
```java
103+
CricinfoSystem system = CricinfoSystem.getInstance();
104+
105+
// Create a new match
106+
Match match = system.createMatch("IND vs AUS", "Melbourne Cricket Ground", new Date());
107+
108+
// Update match status
109+
system.updateMatchStatus(match.getId(), MatchStatus.IN_PROGRESS);
110+
111+
// Record a ball
112+
system.recordBall(match.getId(), 1, 1, "FOUR");
113+
114+
// Get match details
115+
MatchDetails details = system.getMatchDetails(match.getId());
116+
```
117+
118+
---
119+
120+
## Demo
121+
122+
See the demo class for a sample usage and simulation of the cricket information system.
123+
124+
---
125+
126+
## Extending the Framework
127+
128+
- **Add user authentication:** Support for user accounts and preferences
129+
- **Add commentary system:** Real-time match commentary
130+
- **Add statistics engine:** Advanced player and team statistics
131+
- **Add notification system:** Match updates and alerts
132+
- **Add social features:** User comments and discussions
133+
134+
---
135+
136+
## Design Patterns Used
137+
138+
- **Singleton Pattern:** For service classes (MatchService, ScorecardService)
139+
- **Factory Pattern:** For creating matches and scorecards
140+
- **Observer Pattern:** For real-time updates and notifications
141+
- **Strategy Pattern:** For different types of match formats
142+
143+
---

0 commit comments

Comments
 (0)