-
Notifications
You must be signed in to change notification settings - Fork 46
Shelan #29
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
base: master
Are you sure you want to change the base?
Shelan #29
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Class Admin |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # require 'date' | ||
| # | ||
| # class Availibility | ||
| # | ||
| # def range | ||
| # | ||
| # rooms.each do |room, reservation| | ||
| # puts room, reservation | ||
| # end | ||
| # | ||
| # reservation.each do |time| | ||
| # range = (time[:check_in]..time[:check_out]) | ||
| # end | ||
| # return range | ||
| # end | ||
| # | ||
| # def avail_rooms (room_num, time_in, time_out) | ||
| # if range.include(time_in) | ||
| # raise ArgumentError.new("This date is reserved") | ||
| # elsif range.include(time_out) | ||
| # raise ArgumentError.new("This date is reserved") | ||
| # else | ||
| # rooms[:key] = room_num | ||
| # rooms[:key].value << |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| require 'date' | ||
|
|
||
| module Hotel | ||
| class HotelRooms | ||
| attr_reader :rooms, :reservations | ||
|
|
||
| def initialize | ||
| @rooms = [:rooms] | ||
| # fill in hotel rooms | ||
| @reservations = {} | ||
| set_up_rooms #calling this method | ||
| set_up_reservations #calling this method | ||
| end | ||
|
|
||
|
|
||
| def set_up_rooms | ||
| #creates list of hotel rooms | ||
| 19.times do |room_number| | ||
| data = {} | ||
| data[:room_number] = (room_number + 1) | ||
| @rooms << Hotel::Room.new(data) | ||
| end | ||
| return @rooms | ||
| end | ||
|
|
||
| def list_rooms #outputs list of rooms | ||
| return @rooms | ||
| end | ||
|
|
||
| def set_up_reservations #sets reservation's key to room #s | ||
| @reservations = {} | ||
| @reservations.each do |key, value| | ||
| @reservations[key] = @rooms | ||
| end | ||
| return @reservations | ||
| end | ||
| end | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are missing an |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| require 'date' | ||
|
|
||
| module Hotel | ||
| class Reservation | ||
| ROOMCOST = 200 | ||
| attr_accessor :check_in, :check_out, :room_num | ||
| #things that only have to deal with SINGLE ROOM, one reservation at a time | ||
| #monitors overlapping | ||
| def initialize(check_in, check_out, room_num) | ||
| @check_in = check_in | ||
| @check_in = check_out | ||
| @room_num = room_num | ||
| if @room_num > 20 || @room_number < 1 | ||
| raise ArgumentError.new("Number must be between 1 - 20") | ||
| end | ||
| end | ||
|
|
||
| def reserve_room(check_in, check_out, room_num) | ||
| #reserves a room for a given date range | ||
| in = Date.parse(check_in) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are using a keyword here, |
||
| out = Date.parse(check_out) | ||
| @range = (out - in) | ||
|
|
||
| if @reservations[@rooms.last] == room_num | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what this
If none do, then you can create a new reservation instance and add that to the list of reservations. Otherwise indicate an error. However this really isn't the job of an individual |
||
| @reservations[room_num] | ||
| end | ||
| reservations[:room_num].value << @range | ||
| return @reservations | ||
| end | ||
|
|
||
|
|
||
| def total_cost_reservation(check_in, check_out) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| #total cost for a given reservation(given range) | ||
| range = Date.parse(check_out) - Date.parse(check_in) | ||
| real_range = range.to_i | ||
| date_range = real_range - 1 | ||
| cost = date_range * ROOMCOST | ||
| total_cost = "$#{cost}" | ||
| return total_cost | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| module Hotel | ||
| class Room | ||
| #stores information about a hotel room | ||
| attr_reader :room_number | ||
|
|
||
| def initialize(input) | ||
| @room_number = input[:room_number] | ||
| if @room_number > 20 || @room_number < 1 | ||
| raise ArgumentError.new("Number must be between 1 - 20") | ||
| end | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't add your coverage to github |
||
| "result": { | ||
| "covered_percent": 100.0 | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "RSpec": { | ||
| "coverage": { | ||
| }, | ||
| "timestamp": 1536580678 | ||
| } | ||
| } |
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.
What is this method trying to do? Why have a hash of reservations and why have each element point to a list of all the rooms.