Skip to content

Commit

Permalink
solved
Browse files Browse the repository at this point in the history
  • Loading branch information
BohdanZorii committed Dec 19, 2024
1 parent 8845009 commit 36218bb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/mate/academy/TicketBookingSystem.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package mate.academy;

import java.util.concurrent.Semaphore;

public class TicketBookingSystem {
private final Semaphore semaphore;

public TicketBookingSystem(int totalSeats) {

this.semaphore = new Semaphore(totalSeats);
}

public BookingResult attemptBooking(String user) {
return null;
boolean success = semaphore.tryAcquire();
return new BookingResult(user, success,
success ? "Booking successful." : "No seats available.");
}
}

0 comments on commit 36218bb

Please sign in to comment.