Amber Lynn | Edges | Hotel Assignment#38
Conversation
…tion tests for both classes. Working on returning room instance in reservation class
HotelWhat We're Looking For
Hey Amber Lynn! I think you did a lot of good work on this project. In general, I am particularly impressed by the tests you have-- They're thorough and specific and cover all of the implementation code except for the Overall, I think that the design is on a good path: You have a Room to represent something that holds a room number and a price (per night?), a Reservation holds a bunch of data, and you have a Reservation Manager that keeps track of all of them, manages them, and has the logic to manage them and create them. I think that a way to move forward with this project will be to rethink how Reservation Manager keeps track of reservations and the subtleties of how a (potential) reservation could conflict with another existing reservation. I think that the way your code uses this logic correctly (if you have an available room, make a reservation and shovel it into I'm making some comments on some other small things to think about, too! In general, good work and set up to a large project here |
lib/room.rb
Outdated
| attr_accessor :room_number | ||
| attr_reader :price | ||
|
|
||
| ROOM_NUMBERS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] |
There was a problem hiding this comment.
This constant isn't used anywhere in this class!
lib/reservation_mngr.rb
Outdated
|
|
||
| @reservations.each do |reservation| | ||
| if reservation.reservation_id == reservation_id | ||
| return reservation.calculate_cost |
There was a problem hiding this comment.
Here, you call reservation.calculate_cost, which is calling the method calculate_cost on the instance of reservation. Reservation also holds and stores a cost value on it. I think that you could either use reservation.cost since the reservation holds cost on it with .cost, or you should remove the cost variable on reservation so it's not redundant!
spec/reservation_mngr_spec.rb
Outdated
| @front_desk = Hotel::Reservation_mngr.new() | ||
| @room_list = @front_desk.build_room_list | ||
| @front_desk.find_room("01/03/2018", "01/10/2018") | ||
| @rez = [] |
There was a problem hiding this comment.
In these set of tests, you define @rez and don't use it anywhere in the tests-- so it's probably safe to get rid of @rez.
| before do | ||
| @front_desk = Hotel::Reservation_mngr.new() | ||
| @room_list = @front_desk.build_room_list | ||
| @front_desk.find_room("01/03/2018", "01/10/2018") |
There was a problem hiding this comment.
This method gets called, but it doesn't change anything and the return value doesn't get stored anywhere! Do we need this line?
| @reservations << reservation | ||
| if @reservations.length > 20 | ||
| raise ArgumentError | ||
| end |
There was a problem hiding this comment.
@reservations stores all of the reservations made in the whole system. Why does it throw an error if there are more than 20?
For example, what if I made 20 non-conflicting reservations for different dates? Should there be an error thrown when I made the 21st reservation?
lib/reservation_mngr.rb
Outdated
| def initialize | ||
| @rooms = build_room_list | ||
| @reservations = [] | ||
| @current_res_id = 1 |
There was a problem hiding this comment.
You use @current_res_id to store the value of what the next reservation's reservation_id will be. It feels a little weird to me that Reservation_mngr hast to hold onto this, and has to have the logic to deal with this and update it and set it, since that feels kind of like a very brittle way to set Reservation ids. Is there a way we can remove this logic from Reservation_mngr? Also, does a reservation really need an id?
lib/reservation_mngr.rb
Outdated
| rm_avail = true | ||
| @reservations.each do |reservation| | ||
| if room.room_number == reservation.room.room_number | ||
| if Date.strptime(check_in, '%m/%d/%Y') >= reservation.check_in && Date.strptime(check_out, '%m/%d/%Y') < reservation.check_out |
There was a problem hiding this comment.
I think that this conditional doesn't quite work. For example, assume the following things:
room is this:
#<Hotel::Room:0x00007f94d00d2728 @price=200, @room_number=1>
@reservations is this:
[#<Hotel::Reservation:0x00007f94d011bec8
@check_in=#<Date: 2018-01-03 ((2458122j,0s,0n),+0s,2299161j)>,
@check_out=#<Date: 2018-01-10 ((2458129j,0s,0n),+0s,2299161j)>,
@cost=1400,
@reservation_id=1,
@room=#<Hotel::Room:0x00007f94d00d2728 @price=200, @room_number=1>>]
reservation is looking at the only entry in @reservations, so it is this:
#<Hotel::Reservation:0x00007f94d011bec8
@check_in=#<Date: 2018-01-03 ((2458122j,0s,0n),+0s,2299161j)>,
@check_out=#<Date: 2018-01-10 ((2458129j,0s,0n),+0s,2299161j)>,
@cost=1400,
@reservation_id=1,
@room=#<Hotel::Room:0x00007f94d00d2728 @price=200, @room_number=1>>
the value of check_in is "01/03/2018"
the value of check_out is "01/10/2018"
...
Then the dates (check_in: 01/03/2018, checkout: 01/10/2018) and the reservation we're looking at (with check_in: 01/03/2018, checkout: 01/10/2018) should say that this room (room with id 1) is NOT available, but this conditional will evaluate as false, and therefore leave it rm_avail is true (and not go into the next line). This method will return the room with id 1 as the first available room.
| end | ||
|
|
||
| it "returns a room that's available" do | ||
| res_1 = @front_desk.create_reservation("01/03/2018", "01/10/2018") |
There was a problem hiding this comment.
Even though the method create_reservation DOES call find_room within it, this test that is located in the describe block for "find_rooms method" doesn't call find_rooms in it... it'll be a better, more specific and targeted test if the test explicitly calls it.
…ervation and left that responsibility solely to reservation manager. Removed reservation_id from attributes - reservation doesn't need an id if all rerservations can be viewed via @Reservations or by searching for an available room using room number, check_in, and check_out. Currently working on creating a method to display all available rooms (not in reservations).
Hotel
Congratulations! You're submitting your assignment!
Comprehension Questions