Write two seat classes with fields row (String) and number (int):
BrokenSeatoverridesequalsonly;SeatoverridesequalsandhashCode(from the same fields, e.g.Objects.hash(row, number)) andtoString→A1.
HashContract.main reads booking requests row number name. Every request is added to a HashSet<BrokenSeat>. With Seat, a HashSet<Seat> plus a HashMap<Seat, String> refuse double bookings (A1 refused for Mei: already booked by Lina). At the end print the number of requests and the size of each set.
For the input
A 1 Lina
B 2 Omar
A 1 Mei
A 2 Ana
B 2 Bo
the program prints
A1 booked by Lina
B2 booked by Omar
A1 refused for Mei: already booked by Lina
A2 booked by Ana
B2 refused for Bo: already booked by Omar
Requests: 5
Set of Seat (equals + hashCode): 3 seats
Set of BrokenSeat (equals only): 5 seats
equals says A1 = A1: true
Same hash for equal Seats: true