@Test public void testMakeReservation() { final Date now = new Date(); int reservationID1 = ReservationSystem.makeReservation("Abhijit Sarkar", 2, now); Reservation r = ReservationSystem.lookUpReservation("Abhijit Sarkar", now); Assert.assertNotNull(r); int reservationID2 = ReservationSystem.makeReservation("Abhijit Sarkar", 2, now); r = ReservationSystem.lookUpReservation("Abhijit Sarkar", now); Assert.assertNotNull(r); Assert.assertTrue(reservationID2 > reservationID1); }
public static int makeReservation(final String customerName, final int seating, final Date date, final SpecialFeature... specialFeatures) { final Table table = TableManager.reserveTable(seating, specialFeatures); final String formattedDate = format(date); final StringBuilder message = new StringBuilder(); if (table != null) { final Reservation r = new Reservation(reservationNumber.incrementAndGet(), customerName); r.setTables(Arrays.asList(new Table[] { table })); r.setDate(date); addToReservationsList(r, formattedDate); message.append("Made reservation for ").append(customerName).append(" for date ").append(formattedDate) .append(" with seating ").append(seating).append(" and features ").append(specialFeatures) .append("."); LOGGER.info(message.toString()); return r.reservationNumber(); } message.delete(0, message.length() + 1); message.append("No table is available on ").append(formattedDate).append(" with seating ").append(seating) .append(" and features ").append(specialFeatures).append("."); throw new UnableToCompleteReservationException(message.toString()); }
ReservationSystem { public static int makeReservation(final String customerName, final int seating, final Date date, final SpecialFeature... specialFeatures) { final Table table = TableManager.reserveTable(seating, specialFeatures); final String formattedDate = format(date); final StringBuilder message = new StringBuilder(); if (table != null) { final Reservation r = new Reservation(reservationNumber.incrementAndGet(), customerName); r.setTables(Arrays.asList(new Table[] { table })); r.setDate(date); addToReservationsList(r, formattedDate); message.append("Made reservation for ").append(customerName).append(" for date ").append(formattedDate) .append(" with seating ").append(seating).append(" and features ").append(specialFeatures) .append("."); LOGGER.info(message.toString()); return r.reservationNumber(); } message.delete(0, message.length() + 1); message.append("No table is available on ").append(formattedDate).append(" with seating ").append(seating) .append(" and features ").append(specialFeatures).append("."); throw new UnableToCompleteReservationException(message.toString()); } }
ReservationSystem { public static int makeReservation(final String customerName, final int seating, final Date date, final SpecialFeature... specialFeatures) { final Table table = TableManager.reserveTable(seating, specialFeatures); final String formattedDate = format(date); final StringBuilder message = new StringBuilder(); if (table != null) { final Reservation r = new Reservation(reservationNumber.incrementAndGet(), customerName); r.setTables(Arrays.asList(new Table[] { table })); r.setDate(date); addToReservationsList(r, formattedDate); message.append("Made reservation for ").append(customerName).append(" for date ").append(formattedDate) .append(" with seating ").append(seating).append(" and features ").append(specialFeatures) .append("."); LOGGER.info(message.toString()); return r.reservationNumber(); } message.delete(0, message.length() + 1); message.append("No table is available on ").append(formattedDate).append(" with seating ").append(seating) .append(" and features ").append(specialFeatures).append("."); throw new UnableToCompleteReservationException(message.toString()); }  }
ReservationSystem { public static int makeReservation(final String customerName, final int seating, final Date date, final SpecialFeature... specialFeatures) { final Table table = TableManager.reserveTable(seating, specialFeatures); final String formattedDate = format(date); final StringBuilder message = new StringBuilder(); if (table != null) { final Reservation r = new Reservation(reservationNumber.incrementAndGet(), customerName); r.setTables(Arrays.asList(new Table[] { table })); r.setDate(date); addToReservationsList(r, formattedDate); message.append("Made reservation for ").append(customerName).append(" for date ").append(formattedDate) .append(" with seating ").append(seating).append(" and features ").append(specialFeatures) .append("."); LOGGER.info(message.toString()); return r.reservationNumber(); } message.delete(0, message.length() + 1); message.append("No table is available on ").append(formattedDate).append(" with seating ").append(seating) .append(" and features ").append(specialFeatures).append("."); throw new UnableToCompleteReservationException(message.toString()); }  static int makeReservation(final String customerName, final int seating, final Date date,
			final SpecialFeature... specialFeatures); static boolean cancelReservation(final String customerName, final Date date); }
ReservationSystem { public static int makeReservation(final String customerName, final int seating, final Date date, final SpecialFeature... specialFeatures) { final Table table = TableManager.reserveTable(seating, specialFeatures); final String formattedDate = format(date); final StringBuilder message = new StringBuilder(); if (table != null) { final Reservation r = new Reservation(reservationNumber.incrementAndGet(), customerName); r.setTables(Arrays.asList(new Table[] { table })); r.setDate(date); addToReservationsList(r, formattedDate); message.append("Made reservation for ").append(customerName).append(" for date ").append(formattedDate) .append(" with seating ").append(seating).append(" and features ").append(specialFeatures) .append("."); LOGGER.info(message.toString()); return r.reservationNumber(); } message.delete(0, message.length() + 1); message.append("No table is available on ").append(formattedDate).append(" with seating ").append(seating) .append(" and features ").append(specialFeatures).append("."); throw new UnableToCompleteReservationException(message.toString()); }  static int makeReservation(final String customerName, final int seating, final Date date,
			final SpecialFeature... specialFeatures); static boolean cancelReservation(final String customerName, final Date date);  }