This console application allows users to search a list of hotels. Users have the ability to:
- List all hotels
- Search by state
- Search by price
- Add a new hotel
An interesting piece of code in this application. Instead of looping through the entire array, I used a counter variable to keep track of the last position that a hotel was added. Each loop then uses that counter to determine how many times to loop.
for (int i = 0; i <= counter; i++)
{
Hotel hotel = hotels[i];
// only include hotels in the state that the user entered
if(hotel.getPrice() >= min && hotel.getPrice() <= max)
{
displayHotel(hotel);
}
}