Space - Faezeh & Lee#10
Open
theomoondev wants to merge 26 commits into
Open
Conversation
…thod - and method refactor
…es and total_time_spent methods - and method refactor
…passenger has no trips
OO Ride ShareMajor Learning Goals/Code Review
Testing Requirements
Overall Feedback
Code Style Bonus AwardsWas the code particularly impressive in code style for any of these reasons (or more...?)
SummaryVery well done, you hit the learning goals here. Nice work. I like especially how you tested the negative cases for incomplete trips etc. Nice work! |
CheezItMan
reviewed
Mar 2, 2020
| def initialize(id:, name:, vin:, status: :AVAILABLE, trips: nil) | ||
| super(id) | ||
|
|
||
| raise ArgumentError.new("Driver status is not valid") unless %i[AVAILABLE UNAVAILABLE].include?(status) |
There was a problem hiding this comment.
weird, it's indented properly in VS code...
Comment on lines
+31
to
+36
| ratings = [] | ||
| @trips.each do |trip| | ||
| ratings << trip.rating unless trip.rating.nil? | ||
| end | ||
| return @trips.length == 0 ? 0 : (ratings.sum / ratings.length).to_f.round(1) | ||
| end |
There was a problem hiding this comment.
Just note that you can simplify this type of thing with some enumerables. Also indentation is a little weird.
Suggested change
| ratings = [] | |
| @trips.each do |trip| | |
| ratings << trip.rating unless trip.rating.nil? | |
| end | |
| return @trips.length == 0 ? 0 : (ratings.sum / ratings.length).to_f.round(1) | |
| end | |
| completed_trips = trips.select { |trip| !trip.rating.nil? } | |
| return 0 if completed_trips.length == 0 | |
| total_rating = completed_trips.reduce(0) { |sum, trip| sum + trip.rating } | |
| return total_rating / completed_trips.length.to_f |
| expect(RideShare::Driver.new(id: 100, name: "George", vin: "12345678901234567").status).must_equal :AVAILABLE | ||
| end | ||
|
|
||
| it "accepts all legal statuses" do |
| expect(@driver.total_revenue).must_be_close_to 11.34, 0.01 | ||
| end | ||
|
|
||
| it " does not include any in-progress trip" do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Assignment Submission: OO Ride Share
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.
Reflection