Skip to content

Commit 8051bfe

Browse files
committed
Add 10 more LLD problems
1 parent 6679b8d commit 8051bfe

30 files changed

+1677
-88
lines changed

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ This repository contains low level design (LLD) resources to improve object orie
2727
- [Design Stack Overflow](problems/stack-overflow.md)
2828
- [Design Logging Framework](problems/logging-framework.md)
2929
- [Design Coffee Vending Machine](problems/coffee-vending-machine.md)
30+
- [Design Traffic Signal Control System](problems/traffic-signal.md)
31+
- [Design a Task Management System](problems/task-management-system.md)
3032
### Medium
3133
- [Design Pub Sub System](problems/pub-sub-system.md)
3234
- [Design Tic Tac Toe Game](problems/tic-tac-toe.md)
@@ -39,6 +41,10 @@ This repository contains low level design (LLD) resources to improve object orie
3941
- [Design a Library Management System](problems/library-management-system.md)
4042
- [Design Restaurant Management System](problems/restaurant-management-system.md)
4143
- [Design Airline Management System](problems/airline-management-system.md)
44+
- [Design a Digital Wallet System](problems/digital-wallet-system.md)
45+
- [Design an Online Auction System](problems/online-auction-system.md)
46+
- [Design a Vehicle Rental System:](problems/vehicle-rental-system.md)
47+
- [Design a Concert Ticket Booking System](problems/vehicle-rental-system.md)
4248
### Hard
4349
- [Design Movie Ticket Booking System](https://www.youtube.com/watch?v=CC7DwkQOsS0&list=PLAC2AM9O1C5KioUMeH9qIjbAV_RMmX8rd&index=8)
4450
- [Design Splitwise](https://workat.tech/machine-coding/editorial/how-to-design-splitwise-machine-coding-ayvnfo1tfst6)
@@ -47,6 +53,10 @@ This repository contains low level design (LLD) resources to improve object orie
4753
- [Design Online Stock Brokerage System](problems/online-stock-brokerage-system.md)
4854
- [Design CricInfo](https://www.youtube.com/watch?v=VDqwCo6lhkY&list=PLAC2AM9O1C5KioUMeH9qIjbAV_RMmX8rd&index=6)
4955
- [Design Chess Game](problems/chess-game.md)
56+
- [Design Ride-Sharing Service (like Uber)](problems/ride-sharing-service.md)
57+
- [Design Online Food Delivery Service (like Swiggy)](problems/food-delivery-service.md)
58+
- [Design Music Streaming Service (like Spotify)](problems/music-streaming-service.md)
59+
- [Design University Course Registration System](problems/course-registration-system.md)
5060

5161
## Books
5262
- [Head First Design Patterns](https://www.amazon.com/Head-First-Design-Patterns-Object-Oriented/dp/149207800X/)

problems/airline-management-system.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Designing an Airline Management System
22

3-
This blog delves into the object-oriented design and implementation of an Airline Management System using Java.
3+
This article delves into the object-oriented design and implementation of an Airline Management System using Java.
44

55
This system will handle various aspects of airline operations including managing flights, passengers, crew, and aircraft.
66

@@ -20,10 +20,7 @@ The Airline Management System should:
2020
3. **Assigning Crew to Flights**
2121
4. **Managing Aircraft**
2222

23-
## UML/Class Diagrams
24-
25-
Key Classes:
26-
23+
## Key Classes:
2724
- `AirlineManagementSystem`: Manages the entire system.
2825
- `Flight`: Represents a flight.
2926
- `Passenger`: Represents a passenger.

problems/amazon.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Designing an Online Shopping System Like Amazon
22

3-
In this blog post, we're going to design and implement an Online Shopping System resembling Amazon, using Java.
3+
In this article, we're going to design and implement an Online Shopping System resembling Amazon, using Java.
44

55
This system will cover product listings, user accounts, shopping carts, and order processing.
66

@@ -20,10 +20,7 @@ The Online Shopping System should:
2020
3. **Handling Shopping Carts**
2121
4. **Processing Orders**
2222

23-
## UML/Class Diagrams
24-
25-
Key Classes:
26-
23+
## Key Classes:
2724
- `OnlineShoppingSystem`: Manages the overall system.
2825
- `Product`: Represents a product in the catalog.
2926
- `User`: Represents a user of the system.

problems/atm.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Designing an ATM System
22

3-
This guide covers the design and implementation of an Automated Teller Machine (ATM) system using object-oriented programming in Java.
3+
This article covers the design and implementation of an Automated Teller Machine (ATM) system using object-oriented programming in Java.
44

55
## System Requirements
66
Our ATM system is designed to handle:
@@ -15,8 +15,7 @@ Our ATM system is designed to handle:
1515
- **Performing Transactions:** Withdrawals, deposits, balance inquiries.
1616
- **Printing Transaction Receipts** (optional for this implementation)
1717

18-
## UML/Class Diagrams
19-
Key classes include
18+
## Key Classes:
2019
- `ATM`: The main class to interact with users.
2120
- `Account`: To manage account details.
2221
- `Bank`: Represents the bank system that verifies transactions.

problems/car-rental-system.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Designing a Car Rental System
22

3-
In this blog post, we will explore the object-oriented design and implementation of a Car Rental System (CRS) using Java.
3+
In this article, we will explore the object-oriented design and implementation of a Car Rental System (CRS) using Java.
44

55
This system will handle the renting of cars to customers, managing car inventory, and tracking rentals.
66

@@ -20,10 +20,7 @@ The CRS should support:
2020
3. **Tracking Rentals:** View current and past rental records.
2121
4. **Managing Car Inventory:** Add, update, and remove cars from the inventory.
2222

23-
## UML/Class Diagrams
24-
25-
Key classes in the system include:
26-
23+
## Key Classes:
2724
- `CarRentalSystem`: Manages the overall operations of the car rental system.
2825
- `Car`: Represents a car in the system.
2926
- `Rental`: Manages details about a car rental.

problems/chess-game.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Designing a Chess Game
22

3-
In this blog post, we explore the object-oriented design and implementation of a Chess game using Java.
3+
In this article, we explore the object-oriented design and implementation of a Chess game using Java.
44

55
Chess offers an excellent platform to apply object-oriented programming principles due to its complex rules and variety of pieces.
66

@@ -20,10 +20,7 @@ The Chess game should:
2020
3. **Checking Game Status:** Detect check, checkmate, or stalemate.
2121
4. **Ending the Game:** Conclude the game based on the outcome.
2222

23-
## UML/Class Diagrams
24-
25-
Key Classes:
26-
23+
## Key Classes:
2724
- `ChessGame`: Manages overall gameplay.
2825
- `Board`: Represents the chessboard.
2926
- `Piece`: Abstract class for different types of chess pieces.

problems/coffee-vending-machine.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Designing a Coffee Vending Machine
22

3-
This blog post explores the object-oriented design and implementation of a Coffee Vending Machine using Java, a project that demonstrates managing coffee selections, inventory, and customer interactions.
3+
This article explores the object-oriented design and implementation of a Coffee Vending Machine using Java, a project that demonstrates managing coffee selections, inventory, and customer interactions.
44

55
## System Requirements
66

@@ -18,10 +18,7 @@ The Coffee Vending Machine is designed to:
1818
3. **Dispensing Coffee:** Prepare and dispense the chosen coffee.
1919
4. **Processing Payment:** Handle the transaction for the coffee purchase.
2020

21-
## UML/Class Diagrams
22-
23-
Key Classes Involved:
24-
21+
## Key Classes:
2522
- `CoffeeVendingMachine`: Central class managing the vending machine.
2623
- `Coffee`: Enum representing different types of coffee.
2724
- `Ingredient`: Manages individual ingredients.

problems/concert-ticketing-system.md

+198
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
# Designing a Concert Ticket Booking System
2+
3+
In this article, we delve into the object-oriented design and implementation of a Concert Ticket Booking System using Java.
4+
5+
This system facilitates booking tickets for concerts and managing events.
6+
7+
## System Requirements
8+
9+
The Concert Ticket Booking System should:
10+
11+
1. **Event Management**: Manage concert details including dates, venues, and artists.
12+
2. **User Account Management**: Handle user registrations and profiles.
13+
3. **Ticket Booking Process**: Enable users to book tickets and select seats.
14+
4. **Payment Processing**: Handle ticket payments and issue receipts.
15+
5. **Ticket Cancellation and Refund**: Manage cancellations and refunds.
16+
17+
## Core Use Cases
18+
19+
1. **Creating and Managing Concert Events**
20+
2. **Registering and Managing User Accounts**
21+
3. **Booking and Canceling Tickets**
22+
4. **Processing Payments and Issuing Tickets**
23+
5. **Handling Refunds**
24+
25+
## UML/Class Diagrams
26+
27+
Key Classes:
28+
29+
- `ConcertTicketBookingSystem`: Manages the system.
30+
- `User`: Represents a customer.
31+
- `Concert`: Represents a concert event.
32+
- `Ticket`: Manages ticket details.
33+
- `Payment`: Handles payment transactions.
34+
35+
## Java Implementation
36+
37+
### Concert Class
38+
39+
Represents a concert event.
40+
41+
```java
42+
import java.util.Date;
43+
44+
public class Concert {
45+
private String concertId;
46+
private String title;
47+
private Date date;
48+
private String venue;
49+
private int totalSeats;
50+
private int availableSeats;
51+
52+
public Concert(String concertId, String title, Date date, String venue, int totalSeats) {
53+
this.concertId = concertId;
54+
this.title = title;
55+
this.date = date;
56+
this.venue = venue;
57+
this.totalSeats = totalSeats;
58+
this.availableSeats = totalSeats;
59+
}
60+
61+
public boolean bookSeats(int numberOfSeats) {
62+
if (numberOfSeats <= availableSeats) {
63+
availableSeats -= numberOfSeats;
64+
return true;
65+
}
66+
return false;
67+
}
68+
69+
// Getters and setters...
70+
}
71+
```
72+
### User Class
73+
Manages user account information.
74+
```java
75+
public class User {
76+
private String userId;
77+
private String name;
78+
private String email;
79+
80+
public User(String userId, String name, String email) {
81+
this.userId = userId;
82+
this.name = name;
83+
this.email = email;
84+
}
85+
86+
// Getters and setters...
87+
}
88+
```
89+
### Ticket Class
90+
Represents a concert ticket.
91+
```java
92+
public class Ticket {
93+
private String ticketId;
94+
private Concert concert;
95+
private User user;
96+
private int numberOfSeats;
97+
private double totalPrice;
98+
99+
public Ticket(String ticketId, Concert concert, User user, int numberOfSeats, double pricePerSeat) {
100+
this.ticketId = ticketId;
101+
this.concert = concert;
102+
this.user = user;
103+
this.numberOfSeats = numberOfSeats;
104+
this.totalPrice = pricePerSeat * numberOfSeats;
105+
}
106+
107+
// Getters and setters...
108+
}
109+
```
110+
### Payment Class
111+
Handles payment transactions.
112+
```java
113+
public class Payment {
114+
private String paymentId;
115+
private double amount;
116+
private PaymentStatus status;
117+
118+
public Payment(String paymentId, double amount) {
119+
this.paymentId = paymentId;
120+
this.amount = amount;
121+
this.status = PaymentStatus.PENDING;
122+
}
123+
124+
public void completePayment() {
125+
this.status = PaymentStatus.COMPLETED;
126+
}
127+
128+
// Getters and setters...
129+
}
130+
131+
enum PaymentStatus {
132+
PENDING, COMPLETED, FAILED
133+
}
134+
```
135+
### ConcertTicketBookingSystem Class
136+
Manages the concert ticket booking system operations.
137+
138+
```java
139+
import java.util.ArrayList;
140+
import java.util.List;
141+
142+
public class ConcertTicketBookingSystem {
143+
private List<User> users;
144+
private List<Concert> concerts;
145+
private List<Ticket> tickets;
146+
147+
public ConcertTicketBookingSystem() {
148+
this.users = new ArrayList<>();
149+
this.concerts = new ArrayList<>();
150+
this.tickets = new ArrayList<>();
151+
}
152+
153+
public void addUser(User user) {
154+
users.add(user);
155+
}
156+
157+
public void addConcert(Concert concert) {
158+
concerts.add(concert);
159+
}
160+
161+
public Ticket bookTicket(String userId, String concertId, int numberOfSeats) {
162+
User user = findUserById(userId);
163+
Concert concert = findConcertById(concertId);
164+
165+
if (user != null && concert != null && concert.bookSeats(numberOfSeats)) {
166+
double pricePerSeat = // Assume a method to get price per seat
167+
Ticket ticket = new Ticket(generateTicketId(), concert, user, numberOfSeats, pricePerSeat);
168+
tickets.add(ticket);
169+
return ticket;
170+
}
171+
return null;
172+
}
173+
174+
private User findUserById(String userId) {
175+
for (User user : users) {
176+
if (user.getUserId().equals(userId)) {
177+
return user;
178+
}
179+
}
180+
return null;
181+
}
182+
183+
private Concert findConcertById(String concertId) {
184+
for (Concert concert : concerts) {
185+
if (concert.getConcertId().equals(concertId)) {
186+
return concert;
187+
}
188+
}
189+
return null;
190+
}
191+
192+
private String generateTicketId() {
193+
return "TICKET_" + System.currentTimeMillis();
194+
}
195+
196+
// Other necessary methods...
197+
}
198+
```

0 commit comments

Comments
 (0)