Your task is to fix the event tickets tool so that every command updates the data correctly and prints the correct success message or error reason. It reads the state from data/event.json and data/reservations.json, processes the reserve, release and transfer commands, and writes the updated state back.
├── data/
│ ├── event.json # Read-only event limits (event, capacity, per_person_limit)
│ └── reservations.json # Persistent reservations state (reservations)
├── src/
│ ├── main/java/com/tickets/
│ │ ├── Commands.java # Command handlers
│ │ ├── FileIo.java # State file load and save
│ │ ├── Main.java # CLI entry point
│ │ ├── Models.java # Data models
│ │ └── Parser.java # JSON parsing
│ └── test/java/com/tickets/
│ └── CommandsTest.java
├── tickets # CLI launcher script
├── run.sh # Setup and run script
├── reset.sh # Restore data/reservations.json to its initial state
├── test.sh # Test script (writes junit.xml)
├── pom.xml # Maven build configuration
└── README.md
mvn -B -ntp -DskipTests packagebash run.shbash test.shRestore data/reservations.json to its initial state.
bash reset.shEach example below runs independently against the initial data files. Park Movie Night has 27 tickets and a limit of 4 per person. Eight people hold 25 of them, in this order: sam 4, riley 2, jordan 4, casey 1, taylor 4, quinn 3, morgan 4, drew 3. That leaves 2.
Command:
./tickets reserve casey 1Output:
Reserved 1 for casey (2 held, 1 left)
casey afterwards:
{"person":"casey","qty":2}casey held 1, so one more makes 2, and 1 ticket is left.
Command:
./tickets release sam 1Output:
Released 1 for sam (3 held, 3 left)
sam afterwards:
{"person":"sam","qty":3}sam goes from 4 to 3 and the ticket returns to the pool, so 3 are left. A person who gives back everything they hold leaves the list: ./tickets release casey 1 prints Released 1 for casey (0 held, 3 left) and casey's entry is removed.
Commands:
./tickets release riley 3
./tickets release avery 1Output:
Error: NOT_ENOUGH_HELD
Error: NO_RESERVATION
riley holds 2 and avery holds none. Neither command changes the file.
Command:
./tickets transfer quinn riley 2Output:
Transferred 2 from quinn to riley
The two records that change. quinn:
{"person":"quinn","qty":1}riley:
{"person":"riley","qty":4}quinn goes from 3 to 1 and riley from 2 to 4. No ticket leaves or enters the pool, so 2 are still left. ./tickets transfer quinn riley 3 would take riley to 5, over the limit of 4, and answers Error: PER_PERSON_LIMIT.
Commands:
./tickets transfer avery sam 1
./tickets transfer sam sam 1Output:
Error: NO_RESERVATION
Error: SAME_PERSON
avery holds no tickets, and sam cannot transfer to sam. Neither command changes the file.