Question
Create a Java class that a Hotel would use to store a list of the property’s rooms and room specifications (rates, beds, kitchenette, handicapped accessibility) for a total of 30 rooms. 10 Single beds for $99 a night, 10 kitchenette rooms for $159 a night, 5 handicapped accessibility rooms for $109 a night. and 5 double beds for $149 a night. The class should also provide a scanner object for users at the hotel to input that a room is checked out or not, and give them the ability to book a room for a customer. Including an availability check (a command that returns what rooms are available that day) is also required.
Explanation / Answer
package hotel; import java.io.PrintWriter; import java.util.Scanner; import javafx.collections.FXCollections; import javafx.collections.ObservableList; public class Room { private String name; private int capacity; private ObservableList events; public Room() { events = FXCollections.observableArrayList(); } public String getName() { return name; } public boolean allowsEvent(Event newEvent) { if(newEvent.getGroupSize() > capacity) return false; for(Event e : events) { if(e.compareTo(newEvent) == 0) return false; } return true; } public void addEvent(Event newEvent) { events.add(newEvent); FXCollections.sort(events); } public void removeEvent(Event toRemove) { events.remove(toRemove); } public void readFrom(Scanner input) { // Read the room details and events from the file name = input.next() + input.nextLine(); capacity = input.nextInt(); int howManyEvents = input.nextInt(); for(int n = 0;n event.getDate().equals(selectedDate)); eventsList.setItems(filteredEvents); } }