-
Notifications
You must be signed in to change notification settings - Fork 28
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
Sigrid & Barbara, Edges, oo-ride-share #7
base: master
Are you sure you want to change the base?
Conversation
… check in Trip#initialize to check for end time prior to start time.
…uding names and phone numbers.
…TripDispatcher file.
…t. Also corrected driver.add_driven_trip and passenger_as_driver.add_trip lines in load_trips method.
…n method in trip.rb file to handle @end_time value of In Progress.
…lass to ignore trips In Progress.
…s to ignore In Progress trips.
Ride ShareWhat We're Looking For
|
if @end_time == nil | ||
@end_time = "In Progress" | ||
elsif @end_time < @start_time | ||
raise ArgumentError, "End time is before start time" |
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 would much rather have nil
than a string to indicate a trip is in progress.
it "Does not include trips in progress in calculation of total amount spent on trips" do | ||
|
||
run_trip_dispatcher = RideShare::TripDispatcher.new() | ||
trip2 = RideShare::Trip.new(id: 9, driver: nil, passenger: @user, |
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 work getting this edge case. Another one to consider: what if the user has not yet taken a trip?
def net_expenditures | ||
net_expenditures = super | ||
difference = net_expenditures - total_revenue | ||
# difference = super - total_revenue # can use super in place of above code. |
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 super
here.
@driven_trips.each do |x| | ||
# binding.pry | ||
if x.rating == "In Progress" | ||
next |
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 tended to use .each
iteration to calculate totals/sum things in Driver and User, even though things like .sum
is available. Honestly, I don't believe that you ALWAYS need to use fancy Enumerable methods like .sum
over .each
iteration every time, but I want to make sure you know that those are possibilities.
it 'checks if driver.net_expenditures overrides user.net_expenditures' do | ||
difference = @driver.net_expenditures | ||
expect(difference).must_equal 10 - ((4 - 1.65) * 0.80) | ||
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 is a good start, but I believe there are some more interesting cases here. For example, what if a driver has:
- No driven trips
- No trips as a passenger
- An incomplete trip as a driver or passenger
- Made more money than they've spent
|
||
else | ||
return "No available drivers" | ||
# return nil |
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 should either return nil
or raise an exception here, not return a string. There are a number of reasons for this, but ultimately what it comes down to is, in order to check that a string contains an error message, you need to read it.
# Checking for available drivers that do not have the same id as the user requesting a ride | ||
available_drivers = [] | ||
@drivers.each do |x| | ||
if x.status == :AVAILABLE && x.id != user_id.to_i |
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 would be a great piece of logic to move to a helper method.
OO Ride Share
Congratulations! You're submitting your assignment!
Comprehension Questions
User
andDriver