Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Reservation {
- int guestCount;
- int restaurantCapacity;
- boolean isRestaurantOpen;
- boolean isConfirmed;
- public Reservation(int count, int capacity, boolean open) {
- if (count < 1 || count > 8) {
- System.out.println("Invalid reservation!");
- }
- guestCount = count;
- restaurantCapacity = capacity;
- isRestaurantOpen = open;
- }
- public void confirmReservation() {
- if (restaurantCapacity >= guestCount && isRestaurantOpen) {
- System.out.println("Reservation confirmed");
- isConfirmed = true;
- } else {
- System.out.println("Reservation denied");
- isConfirmed = false;
- }
- }
- public void informUser() {
- // Write conditional here
- if (!isConfirmed) {
- System.out.println("Unable to confirm reservation, please contact resturant.");
- } else {
- System.out.println("Please enjoy your meal!");
- }
- }
- public static void main(String[] args) {
- Reservation partyOfThree = new Reservation(3, 12, true);
- Reservation partyOfFour = new Reservation(4, 3, true);
- partyOfThree.confirmReservation();
- partyOfThree.informUser();
- partyOfFour.confirmReservation();
- partyOfFour.informUser();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement