-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Karis - Edges - Hotel #27
base: master
Are you sure you want to change the base?
Conversation
…3 instance variables are created
…ser wants to book
…at will be reserved
…the booking system class
…e same as another bookings checkout date
…eservation due to difficulties with this project
HotelWhat We're Looking For
Hey Karis! You and I have talked together: this was a rough project. You had gone through with one path of development, and ultimately rolled back/didn't submit that version, and the version I see here is a work in progress. It's fine, and I am writing a review of your code to evaluate it on the code that's here and how I feel continuing this code would look like. I see the beginnings of a BookingSystem whose responsibility is to hold references to all of the rooms and existing reservations, and to make reservations. I also see a ReservationCreator whose responsibility seems to be to represent a single reservation-- the info associated with one, like a start date, end date, and to calculate its own booking cost. I'm leaving some comments about where the code could be better, and they mostly revolve around these ideas:
Your tests are a pretty good start too -- the tests describe the facts of the state/attributes of each class. For all attributes on a BookingSystem, what data type are they? That's a good start-- the tests that should follow are for testing the behaviors of each class... When a class does something, what do we expect the result of that action equal? While the code presented here ends up being a "red" grading here because it doesn't meet the standards/requirements of the project, I would like to repeat a few of the thoughts we went over in our last conversation: When there is a project with more direction, I'll want to see more practice on syntax and concepts, and when there is a project with less direction (like this one!), I'll want to see the wrestling with decision-making. Lastly, I feel that I didn't get to talk with you about this face-to-face: |
lib/reservation_creator.rb
Outdated
require 'date' | ||
|
||
module Hotel | ||
class ReservationCreator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I look at this class, it really feels like the attributes, state, behaviors that this class has resemble more of representing a Reservation.
If this object were a "ReservationCreator," I would imagine that its behaviors would be more about making Reservation instances, and wouldn't need a check in or check out date.
lib/reservation_creator.rb
Outdated
@check_in_date = Date.parse("#{input[:check_in_date]}") | ||
|
||
@check_out_date = Date.parse("#{input[:check_out_date]}") | ||
raise StandardError, "Checkout date cannot be before checkin date" unless input[:check_in_date] < input[:check_out_date] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this post-fix conditional! But watch your indentation ;)
lib/reservation_creator.rb
Outdated
|
||
@check_out_date = Date.parse("#{input[:check_out_date]}") | ||
raise StandardError, "Checkout date cannot be before checkin date" unless input[:check_in_date] < input[:check_out_date] | ||
@room_number = input[:room_number].nil? ? [] : input[:room_number] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code says: if in the passed-in input
hash, there is no value defined for the key :room_number
, then the value of @room_number
should be assigned to the empty array []
. Otherwise it will be assigned the value of input[:room_number]
.
I think it makes sense that @room_number
is input[:room_number]
if it exists, but should it be assigned to an empty array if there was no given room number?
@reservations << reservation | ||
|
||
return reservation | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think from a birds-eye view, this method make_reservation
is set up for success. It's outline is the following:
- Figure out what the room number of the next available room is
- Make a new instance of reservation with the following info: the passed in check in date, check out date, and the room number from step 1
- add that reservation to the collection of reservations being recorded in this class on
@reservations
- return that reservation
I think that the rest of the work for wave 2 is just filling in the detail for those steps, and those details will be filled in with the helper methods. I think that this method looks really good as is though.
end | ||
|
||
return bookings_by_date | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method looks pretty good to me. I see the following logic:
We start with figuring out the specific_date
that we'll be comparing things to, and an empty collection in bookings_by_date
.
Looking through the entire collection of reservations in @reservations
, for every reservation, we'll get to see look at every set of dates that each reservation holds... then we'll make a comparison: if those dates include the specific date we were looking at, then we'll add the reservation/booking to the collection bookings_by_date.
Not bad -- can't wait to see more!
end | ||
|
||
def get_available_room(check_in_date:, check_out_date:) | ||
return @rooms.first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love to get more insight into your thoughts here of how you wanted to continue and push this code -- feel free to add comments that include your pseudocode next time :)
…ange, test coverage 100%
… to assign next room number
Hotel
Congratulations! You're submitting your assignment!
Comprehension Questions