-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8845009
commit 36218bb
Showing
1 changed file
with
7 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
} | ||
} |