Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.io.Serializable; import java.text.DecimalFormat; public class Reservation implements Serializable { ///////////////////////////////////////////////////////////////////////////////////////// // Instance Variables ///////////////////////////////////////////////////////////////////////////////////////// // TODO 1: Add code to create instance variables encapsulating

image text in transcribed

import java.io.Serializable; import java.text.DecimalFormat;

public class Reservation implements Serializable { ///////////////////////////////////////////////////////////////////////////////////////// // Instance Variables ///////////////////////////////////////////////////////////////////////////////////////// // TODO 1: Add code to create instance variables encapsulating the reservation described // in the project prompt... ///////////////////////////////////////////////////////////////////////////////////////// // Overloaded Constructor ///////////////////////////////////////////////////////////////////////////////////////// public Reservation(long hotId, int inMonth, int outMonth, int inDay, int outDay) { // TODO 2: Add code to finish overloaded constructor (works as expected)... } ///////////////////////////////////////////////////////////////////////////////////////// // Overloaded constructor #2 ///////////////////////////////////////////////////////////////////////////////////////// public Reservation(long hotId, int month, int inDay, int outDay) { // TODO 3: Add code to finish default constructor (you are free to pick default values)... }

///////////////////////////////////////////////////////////////////////////////////////// // Class Methods ///////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// // Generating display String for printout (kind of like the toString() method). Should be // in the following form: // 1/1 - 1/2 ///////////////////////////////////////////////////////////////////////////////////////// public String getFormattedDisplayString() { // TODO 4: Add code to complete method... } ///////////////////////////////////////////////////////////////////////////////////////// // Generating display String for printout (kind of like the toString() method). Should be // in the following form: // 1/5 - 1/6 @ $179.00 per night ///////////////////////////////////////////////////////////////////////////////////////// public String getFormattedDisplayString(double currentPrice) { // TODO 5: Add code to complete method... } ///////////////////////////////////////////////////////////////////////////////////////// // Getters/Setters ///////////////////////////////////////////////////////////////////////////////////////// // TODO 6: 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 "ArrayList reservations" member variable). This general pattern is modeled in the templates. 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 "ArrayList reservations" member variable). This general pattern is modeled in the templates

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

Briefly describe Aristotles four kinds of causation.

Answered: 1 week ago

Question

Identify and define the eight channels of nonverbal communication

Answered: 1 week ago