Question
import java.text.DecimalFormat; import java.util.ArrayList; public class Hotel { ///////////////////////////////////////////////////////////////////////////////////////// // Instance Variables ///////////////////////////////////////////////////////////////////////////////////////// // TODO 7: Add code to create instance variables encapsulating info found
import java.text.DecimalFormat; import java.util.ArrayList;
public class Hotel { ///////////////////////////////////////////////////////////////////////////////////////// // Instance Variables ///////////////////////////////////////////////////////////////////////////////////////// // TODO 7: Add code to create instance variables encapsulating info found in Hotels.txt... ///////////////////////////////////////////////////////////////////////////////////////// // Overloaded Constructor ///////////////////////////////////////////////////////////////////////////////////////// public Hotel(long id, String name, String addr, String cityName, String stAbbrev, double price) { // TODO 8: Add code to finish overloaded constructor (works as expected)... } ///////////////////////////////////////////////////////////////////////////////////////// // Default constructor ///////////////////////////////////////////////////////////////////////////////////////// public Hotel() { // TODO 9: Add code to finish default constructor (you are free to pick default values)... } ///////////////////////////////////////////////////////////////////////////////////////// // Class Methods ///////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// // This method takes in a new reservation and compares it against // all other reservations in this hotels reservations ArrayList. // Returns true if the new reservation can be made; returns false // if the new reserveration (newRes) will conflict with an old // reservation. ///////////////////////////////////////////////////////////////////////////////////////// public boolean canBook(Reservation newRes) { // TODO 10: Add code to complete method... } ///////////////////////////////////////////////////////////////////////////////////////// // Adds the new reservation (newRes) to the ArrayList of reservations // (instance variables) ///////////////////////////////////////////////////////////////////////////////////////// public void addReservation(Reservation newRes) { // TODO 11: Add code to complete method... } ///////////////////////////////////////////////////////////////////////////////////////// // SIMPLE method that uses the previous two methods (canBook() and addReservation()). If // canBook() returns true, calls addReservation() to add newRes and returns true; // otherwise, returns false. ///////////////////////////////////////////////////////////////////////////////////////// public boolean addResIfCanBook(Reservation newRes) { // TODO 12: Add code to complete method... } ///////////////////////////////////////////////////////////////////////////////////////// // Generating display String for printout (kind of like the toString() method). Should be // in the following form: // 1) Azusa Inn (23 Main St., Azusa, CA) @ $159.00ight // // NOTE: In this example, the "1)" is the uniqueId of this hotel, "Azusa Inn", is the // name of the hotel, etc., etc... ///////////////////////////////////////////////////////////////////////////////////////// public String toDisplayString() { // TODO 13: Add code to complete method... } ///////////////////////////////////////////////////////////////////////////////////////// // Getters/Setters ///////////////////////////////////////////////////////////////////////////////////////// // TODO 14: Add code to create ALL getters/setters (REMINDER: Eclipse can do this for you // if you've already created the instance variables)... }
Requirements 1. Your program must first read from the included Hotels.txt file. It contains a number of lines of data; each line corresponds to a hotel in your chain (you may add more if you'd like and your code should not break). Each line is formatted as follows: Hotel(uniqueld, hotelName, streetAddress, city, stateAbbreviation, pricePerNight) You will need to create a simple Hotel class to encapsulate this data (template provided). 2. Your program must ask the user which hotel they'd like to stay in by listing all the hotels (with prices, address, etc.) with a number to the side, and then prompting the user to select a hotel by entering the corresponding number (corresponding to the unique ID). Once they've selected a hotel, you need to prompt the user for check-in month/day and check-out month/day. If they enter two different months, inform them that hotel policy does not allow them to check out during a different month (we have some interesting rules) and ask them to try again until they enter a valid range. Once they enter a valid range, according to the last paragraph, you must check all previously made reservations (which you will be storing in a file). If there is no conflicting reservation, inform the user that their reservation was successful and tell them how much they will owe for their entire stay (don't worry about tax). If there is a conflict with a previous booking, then inform the user and allow them to try different dates. The included runnable jar file will demonstrate exact syntax (all months and days will be entered as integers) and flow (template provides most of syntax/flow for you). 3. When you make a reservation, you must store it in a separate file (call it Reservations.txt) such that it can be referenced when the program is opened to make a reservation with a new customer later. Create a Reservation class to encapsulate this concept. To associate a particular reservation (which basically consists of the check-in month/day, check-out month/day) with a particular hotel, you will also need to store a hotel id (same thing as the hotel's uniqueld) in the Reservation which directly corresponds to one of the hotel unique ids. You must use serialization techniques to save the reservations to a file. HINT: You should create a Reservation class (template file provided), which encapsulates the above idea. You could then add an ArrayList of Reservations to your Hotel class. After you read in and create your hotel objects, you'd read in the reservations from file and add them to the hotel's reservation ArrayList (i.e., it would be a good idea for the Hotel class to have an "ArrayListStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started