-
Notifications
You must be signed in to change notification settings - Fork 35
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
Water: Leah & Sophia #26
base: master
Are you sure you want to change the base?
Conversation
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.
Great job! It looks like you need to practice your edge case tests a little more but other than that everything looked good!
OO Ride Share
Major Learning Goals/Code Review
Criteria | yes/no, and optionally any details/lines of code to reference |
---|---|
The code demonstrates individual learning about Time and the responsibility of Trip.from_csv , and uses Time.parse in Trip.from_csv |
✔️ |
The code demonstrates breaking out complex logic in helper methods, such as making a helper method in Trip to calculate duration |
✔️ |
There are tests for the nominal cases for the Passenger#net_expenditures and Passenger#total_time_spent |
✔️ |
There is at least one edge case test for either Passenger#net_expenditures or Passenger#total_time_spent testing if the passenger has no trips |
No edge case test. |
Practices inheritance. Driver inherits from CsvRecord , and implements from_csv |
✔️ |
Employs problem-solving and implements Driver#average_rating and Driver#total_revenue |
✔️ |
Implements the TripDispatcher#request_trip , which creates an instance of Trip with a driver and passenger, adds the new trip to @trips , and changes the status of the driver |
✔️ |
Practices composition. In TripDispatcher#request_trip , the driver gets connected to the new trip, the passenger gets connected to the new trip |
✔️ |
Practices git with at least 10 small commits and meaningful commit messages | ✔️ |
Testing Requirements
Testing Requirement | yes/no |
---|---|
There is reasonable test coverage for wave 1, and all wave 1 tests pass | ✔️ |
There is reasonable test coverage for wave 2, and all wave 2 tests pass | ✔️ |
Wave 3: Tests in wave 1 and wave 2 explicitly test that only completed trips should be calculated (and ignore in-progress trips) | Only tests nominal case. |
There is reasonable test coverage for TripDispatcher#request_trip , and all tests pass |
✔️ |
Overall Feedback
Overall Feedback | Criteria | yes/no |
---|---|---|
Green (Meets/Exceeds Standards) | 8+ in Code Review && 3+ in Functional Requirements | ✔️ |
Yellow (Approaches Standards) | 6+ in Code Review && 2+ in Functional Requirements | |
Red (Not at Standard) | 0-5 in Code Review or 0,1 in Functional Reqs, or assignment is breaking/doesn’t run with less than 5 minutes of debugging |
Code Style Bonus Awards
Was the code particularly impressive in code style for any of these reasons (or more...?)
Quality | Yes? |
---|---|
Perfect Indentation | ✅ |
Elegant/Clever | ✅ |
Descriptive/Readable | ✅ |
Concise | ✅ |
Logical/Organized | ✅ |
|
||
@name = name | ||
@vin = vin | ||
raise ArgumentError.new("Invalid VIN") if (vin.length) != 17 |
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.
It's helpful for debugging to include the bad argument in your variable:
raise ArgumentError.new("Invalid VIN") if (vin.length) != 17 | |
raise ArgumentError.new("Invalid VIN: #{vin}") if (vin.length) != 17 |
def accept_new_trip(trip) | ||
add_trip(trip) | ||
@status = :UNAVAILABLE | ||
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.
You might want to verify that the driver is available before accepting a trip.
def average_rating | ||
ratings_array = @trips.reject { |trip| trip.rating == nil }.map(&:rating) | ||
return 0 if (@trips) == [] || @trips == nil | ||
return (ratings_array.sum/ratings_array.length).to_f | ||
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.
You should move this check up. If @trips
is nil
you will get an error when you call @trips.reject
:
def average_rating | |
ratings_array = @trips.reject { |trip| trip.rating == nil }.map(&:rating) | |
return 0 if (@trips) == [] || @trips == nil | |
return (ratings_array.sum/ratings_array.length).to_f | |
end | |
def average_rating | |
return 0 if (@trips) == [] || @trips == nil | |
ratings_array = @trips.reject { |trip| trip.rating == nil }.map(&:rating) | |
return (ratings_array.sum/ratings_array.length).to_f | |
end |
end | ||
|
||
def average_rating | ||
ratings_array = @trips.reject { |trip| trip.rating == nil }.map(&:rating) |
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.
Great use of enumerable methods!
|
||
if @rating > 5 || @rating < 1 | ||
|
||
if @rating != nil && (@rating > 5 || @rating < 1) | ||
raise ArgumentError.new("Invalid rating #{@rating}") |
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.
Nice job including the bad argument here!
total_expenditure = @trips.sum(&:cost) | ||
return total_expenditure |
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 can directly return @trips.sum(&:cost)
:
total_expenditure = @trips.sum(&:cost) | |
return total_expenditure | |
return @trips.sum(&:cost) |
(This saves you from having to come up with a variable name.)
trip_data = { | ||
id: @trips.length + 1, | ||
passenger: passenger, | ||
start_time: start_time, | ||
end_time: end_time, | ||
cost: nil, | ||
rating: nil, | ||
driver_id: driver.id, | ||
driver: driver | ||
} | ||
|
||
new_trip_instance = RideShare::Trip.new(trip_data) |
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 got a warning for this. To fix it directly use keyword arguments instead of passing in a hash:
trip_data = { | |
id: @trips.length + 1, | |
passenger: passenger, | |
start_time: start_time, | |
end_time: end_time, | |
cost: nil, | |
rating: nil, | |
driver_id: driver.id, | |
driver: driver | |
} | |
new_trip_instance = RideShare::Trip.new(trip_data) | |
new_trip_instance = RideShare::Trip.new( | |
id: @trips.length + 1, | |
passenger: passenger, | |
start_time: start_time, | |
end_time: end_time, | |
cost: nil, | |
rating: nil, | |
driver_id: driver.id, | |
driver: driver | |
) |
Assignment Submission: OO Ride Share
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.
Reflection
)
expect(@driver.total_revenue).must_equal 0
end
What is a concept that you gained more clarity on as you worked on this assignment | TDD, we both gained a better understanding of how to write and read tests.