-
Notifications
You must be signed in to change notification settings - Fork 45
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
Marisa Morris - Carets #23
base: master
Are you sure you want to change the base?
Conversation
…to initialize method.
…hat wasnt needed).
…lass. block rate method tests passing
HotelWhat We're Looking For
|
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.
Notes on your code.
@cost = cost | ||
end | ||
|
||
def block_rate |
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.
Shouldn't you simply override the rate
method?
Why create the same method by a different name in a subclass?
|
||
def rate | ||
nights = @check_out_date - @check_in_date | ||
@cost = nights.to_i * Room::RATE |
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.
You set the cost to a different value in initialize
. Why?
class Room | ||
attr_reader :room_number | ||
|
||
RATE = 200 |
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.
Good use of a constant!
class Hotel | ||
attr_reader :rooms, :reservations, :found_reservations, :unreserved_rooms, :blocks | ||
def initialize | ||
@rooms = [] |
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.
If you're setting @rooms
to []
in initialize, why do you have an add_20_rooms
method. I would suggest instead making add_20_rooms
private and calling it from initialize
. I would also suggest renaming it to something less specific as to the implementation (number of rooms). That way you could extend or subclass Hotel
and override the method to change the number of rooms.
|
||
# creates a reservation | ||
def create_reservation(first_name, last_name, check_in_date, check_out_date, 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.
The Reservation
class should be checking for it being created with invalid dates.
|
||
|
||
def reservations_by_date(date) | ||
@reservations.each { |reservation| |
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.
Good use of enumerables in this project.
…e_reservation method with the Hotel class & updated the create block method in the Hotel class
Hotel
Congratulations! You're submitting your assignment!
Comprehension Questions