Skip to content

Commit

Permalink
update readme of interview problems
Browse files Browse the repository at this point in the history
  • Loading branch information
ashishps1 committed Jul 2, 2024
1 parent 8222420 commit d7eff32
Show file tree
Hide file tree
Showing 33 changed files with 374 additions and 306 deletions.
26 changes: 14 additions & 12 deletions problems/airline-management-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
7. The system should ensure data consistency and handle concurrent access to shared resources.
8. The system should be scalable and extensible to accommodate future enhancements and new features.

### Java Implementation
[Full Code](../solutions/java/src/airlinemanagementsystem/)
## Implementations
#### [Java Implementation](../solutions/java/src/airlinemanagementsystem/)
#### [Python Implementation](../solutions/python/airlinemanagementsystem/)

1. The Flight class represents a flight in the airline management system, with properties such as flight number, source, destination, departure time, arrival time, and available seats.
2. The Aircraft class represents an aircraft, with properties like tail number, model, and total seats.
3. The Passenger class represents a passenger, with properties such as ID, name, email, and phone number.
4. The Booking class represents a booking made by a passenger for a specific flight and seat, with properties such as booking number, flight, passenger, seat, price, and booking status.
5. The Seat class represents a seat on a flight, with properties like seat number, seat type, and seat status.
6. The Payment class represents a payment made for a booking, with properties such as payment ID, payment method, amount, and payment status.
7. The FlightSearch class provides functionality to search for flights based on source, destination, and date.
8. The BookingManager class manages the creation and cancellation of bookings. It follows the Singleton pattern to ensure a single instance of the booking manager.
9. The PaymentProcessor class handles the processing of payments. It follows the Singleton pattern to ensure a single instance of the payment processor.
10. The AirlineManagementSystem class serves as the main entry point of the system, combining all the components and providing methods for flight management, booking, payment processing, and other operations.
## Classes, Interfaces and Enumerations
1. The **Flight** class represents a flight in the airline management system, with properties such as flight number, source, destination, departure time, arrival time, and available seats.
2. The **Aircraft** class represents an aircraft, with properties like tail number, model, and total seats.
3. The **Passenger** class represents a passenger, with properties such as ID, name, email, and phone number.
4. The **Booking** class represents a booking made by a passenger for a specific flight and seat, with properties such as booking number, flight, passenger, seat, price, and booking status.
5. The **Seat** class represents a seat on a flight, with properties like seat number, seat type, and seat status.
6. The **Payment** class represents a payment made for a booking, with properties such as payment ID, payment method, amount, and payment status.
7. The **FlightSearch** class provides functionality to search for flights based on source, destination, and date.
8. The **BookingManager** class manages the creation and cancellation of bookings. It follows the Singleton pattern to ensure a single instance of the booking manager.
9. The **PaymentProcessor** class handles the processing of payments. It follows the Singleton pattern to ensure a single instance of the payment processor.
10. The **AirlineManagementSystem** class serves as the main entry point of the system, combining all the components and providing methods for flight management, booking, payment processing, and other operations.
20 changes: 11 additions & 9 deletions problems/atm.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
5. The system should handle concurrent access and ensure data consistency.
6. The ATM should have a user-friendly interface for users to interact with.

### Java Implementation
[Full code](../solutions/java/src/atm/)
## Implementations
#### [Java Implementation](../solutions/java/src/atm/)
#### [Python Implementation](../solutions/python/atm/)

1. The Card class represents an ATM card with a card number and PIN.
2. The Account class represents a bank account with an account number and balance. It provides methods to debit and credit the account balance.
3. The Transaction class is an abstract base class for different types of transactions, such as withdrawal and deposit. It is extended by WithdrawalTransaction and DepositTransaction classes.
4. The BankingService class manages the bank accounts and processes transactions. It uses a thread-safe ConcurrentHashMap to store and retrieve account information.
5. The CashDispenser class represents the ATM's cash dispenser and handles the dispensing of cash. It uses synchronization to ensure thread safety when dispensing cash.
6. The ATM class serves as the main interface for ATM operations. It interacts with the BankingService and CashDispenser to perform user authentication, balance inquiry, cash withdrawal, and cash deposit.
7. The ATMDriver class demonstrates the usage of the ATM system by creating sample accounts and performing ATM operations.
## Classes, Interfaces and Enumerations
1. The **Card** class represents an ATM card with a card number and PIN.
2. The **Account** class represents a bank account with an account number and balance. It provides methods to debit and credit the account balance.
3. The **Transaction** class is an abstract base class for different types of transactions, such as withdrawal and deposit. It is extended by WithdrawalTransaction and DepositTransaction classes.
4. The **BankingService** class manages the bank accounts and processes transactions. It uses a thread-safe ConcurrentHashMap to store and retrieve account information.
5. The **CashDispenser** class represents the ATM's cash dispenser and handles the dispensing of cash. It uses synchronization to ensure thread safety when dispensing cash.
6. The **ATM** class serves as the main interface for ATM operations. It interacts with the BankingService and CashDispenser to perform user authentication, balance inquiry, cash withdrawal, and cash deposit.
7. The **ATMDriver** class demonstrates the usage of the ATM system by creating sample accounts and performing ATM operations.
20 changes: 11 additions & 9 deletions problems/car-rental-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
7. The system should handle payment processing for reservations.
8. The system should be able to handle concurrent reservations and ensure data consistency.

### Java Implementation
[Full Code](../solutions/java/src/carrentalsystem/)
## Implementations
#### [Java Implementation](../solutions/java/src/carrentalsystem/)
#### [Python Implementation](../solutions/python/carrentalsystem/)

1. The Car class represents a car in the rental system, with properties such as make, model, year, license plate number, rental price per day, and availability status.
2. The Customer class represents a customer, with properties like name, contact information, and driver's license number.
3. The Reservation class represents a reservation made by a customer for a specific car and date range. It includes properties such as reservation ID, customer, car, start date, end date, and total price.
4. The PaymentProcessor interface defines the contract for payment processing, and the CreditCardPaymentProcessor and PayPalPaymentProcessor classes are concrete implementations of the payment processor.
5. The RentalSystem class is the core of the car rental system and follows the Singleton pattern to ensure a single instance of the rental system.
## Classes, Interfaces and Enumerations
1. The **Car** class represents a car in the rental system, with properties such as make, model, year, license plate number, rental price per day, and availability status.
2. The **Customer** class represents a customer, with properties like name, contact information, and driver's license number.
3. The **Reservation** class represents a reservation made by a customer for a specific car and date range. It includes properties such as reservation ID, customer, car, start date, end date, and total price.
4. The **PaymentProcessor** interface defines the contract for payment processing, and the CreditCardPaymentProcessor and PayPalPaymentProcessor classes are concrete implementations of the payment processor.
5. The **RentalSystem** class is the core of the car rental system and follows the Singleton pattern to ensure a single instance of the rental system.
6. The RentalSystem class uses concurrent data structures (ConcurrentHashMap) to handle concurrent access to cars and reservations.
7. The RentalSystem class provides methods for adding and removing cars, searching for available cars based on criteria, making reservations, canceling reservations, and processing payments.
8. The CarRentalSystem class serves as the entry point of the application and demonstrates the usage of the car rental system.
7. The **RentalSystem** class provides methods for adding and removing cars, searching for available cars based on criteria, making reservations, canceling reservations, and processing payments.
8. The **CarRentalSystem** class serves as the entry point of the application and demonstrates the usage of the car rental system.
18 changes: 10 additions & 8 deletions problems/chess-game.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
7. The game should handle player turns and allow players to make moves alternately.
8. The game should provide a user interface for players to interact with the game.

### Java Implementation
[Full Code](../solutions/java/src/chessgame/)
## Implementations
#### [Java Implementation](../solutions/java/src/chessgame/)
#### [Python Implementation](../solutions/python/chessgame/)

1. The Piece class is an abstract base class representing a chess piece. It contains common attributes such as color, row, and column, and declares an abstract method canMove to be implemented by each specific piece class.
2. The King, Queen, Rook, Bishop, Knight, and Pawn classes extend the Piece class and implement their respective movement logic in the canMove method.
3. The Board class represents the chess board and manages the placement of pieces. It provides methods to get and set pieces on the board, check the validity of moves, and determine checkmate and stalemate conditions.
4. The Player class represents a player in the game and has a method to make a move on the board.
## Classes, Interfaces and Enumerations
1. The **Piece** class is an abstract base class representing a chess piece. It contains common attributes such as color, row, and column, and declares an abstract method canMove to be implemented by each specific piece class.
2. The **King**, **Queen**, **Rook**, **Bishop**, **Knight**, and **Pawn** classes extend the Piece class and implement their respective movement logic in the canMove method.
3. The **Board** class represents the chess board and manages the placement of pieces. It provides methods to get and set pieces on the board, check the validity of moves, and determine checkmate and stalemate conditions.
4. The **Player** class represents a player in the game and has a method to make a move on the board.
5. The Move class represents a move made by a player, containing the piece being moved and the destination coordinates.
6. The Game class orchestrates the overall game flow. It initializes the board, handles player turns, and determines the game result.
7. The ChessGame class is the entry point of the application and starts the game.
6. The **Game** class orchestrates the overall game flow. It initializes the board, handles player turns, and determines the game result.
7. The **ChessGame** class is the entry point of the application and starts the game.
18 changes: 10 additions & 8 deletions problems/coffee-vending-machine.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
6. The machine should track the inventory of ingredients and notify when they are running low.
7. The machine should handle multiple user requests concurrently and ensure thread safety.

## Java Implementation
[Full Code](../solutions/java/src/coffeevendingmachine/)
## Implementations
#### [Java Implementation](../solutions/java/src/coffeevendingmachine/)
#### [Python Implementation](../solutions/python/coffeevendingmachine/)

1. The Coffee class represents a coffee type with its name, price, and recipe (ingredients and their quantities).
2. The Ingredient class represents an ingredient used in making coffee, with its name and quantity. It provides a synchronized method to update the quantity.
3. The Payment class represents a payment made by a user, with the amount paid.
4. The CoffeeMachine class is the main class that manages the coffee vending machine. It follows the Singleton pattern to ensure a single instance of the machine.
5. The CoffeeMachine class initializes the coffee menu and ingredients in its constructor. It provides methods to display the menu, select a coffee, dispense coffee, and update ingredient quantities.
## Classes, Interfaces and Enumerations
1. The **Coffee** class represents a coffee type with its name, price, and recipe (ingredients and their quantities).
2. The **Ingredient** class represents an ingredient used in making coffee, with its name and quantity. It provides a synchronized method to update the quantity.
3. The **Payment** class represents a payment made by a user, with the amount paid.
4. The **CoffeeMachine** class is the main class that manages the coffee vending machine. It follows the Singleton pattern to ensure a single instance of the machine.
5. The **CoffeeMachine** class initializes the coffee menu and ingredients in its constructor. It provides methods to display the menu, select a coffee, dispense coffee, and update ingredient quantities.
6. The hasEnoughIngredients method checks if there are sufficient ingredients to make a selected coffee, while the updateIngredients method updates the ingredient quantities after dispensing a coffee.
7. The CoffeeVendingMachine class is the entry point of the application and demonstrates the usage of the coffee vending machine. It creates an instance of the machine, displays the menu, and simulates concurrent user requests using an ExecutorService.
7. The **CoffeeVendingMachine** class is the entry point of the application and demonstrates the usage of the coffee vending machine. It creates an instance of the machine, displays the menu, and simulates concurrent user requests using an ExecutorService.
24 changes: 13 additions & 11 deletions problems/concert-ticketing-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@
7. The system should generate booking confirmations and send them to users via email or SMS.
8. The system should provide a waiting list functionality for sold-out concerts.

### Java Implementation
[Full Code](../solutions/java/src/concertbookingsystem/)
## Implementations
#### [Java Implementation](../solutions/java/src/concertbookingsystem/)
#### [Python Implementation](../solutions/python/concertbookingsystem/)

1. The Concert class represents a concert event, with properties such as ID, artist, venue, date and time, and a list of seats.
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.
3. The SeatType enum represents the different types of seats available, such as regular, premium, and VIP.
4. The SeatStatus enum represents the status of a seat, which can be available, booked, or reserved.
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.
6. The BookingStatus enum represents the status of a booking, which can be pending, confirmed, or cancelled.
7. The User class represents a user of the concert ticket booking system, with properties like ID, name, and email.
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.
9. The SeatNotAvailableException is a custom exception used to handle cases where a seat is not available for booking.
## Classes, Interfaces and Enumerations
1. The **Concert** class represents a concert event, with properties such as ID, artist, venue, date and time, and a list of seats.
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.
3. The **SeatType** enum represents the different types of seats available, such as regular, premium, and VIP.
4. The **SeatStatus** enum represents the status of a seat, which can be available, booked, or reserved.
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.
6. The **BookingStatus** enum represents the status of a booking, which can be pending, confirmed, or cancelled.
7. The **User** class represents a user of the concert ticket booking system, with properties like ID, name, and email.
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.
9. The **SeatNotAvailableException** is a custom exception used to handle cases where a seat is not available for booking.
Loading

0 comments on commit d7eff32

Please sign in to comment.