Haben, Hannah, Angela - TIME #22
Conversation
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...?)
SummaryYou have some minor indentation issues here, like in lines 23-28 in trip_test.rb. Nice work, you hit the main learning goals here. Well done in waves 1-3. Take a look at my inline comments and let me know if you have any questions. |
| end | ||
|
|
||
| it "stores an instance of driver" do | ||
| skip # Unskip after wave 2 |
There was a problem hiding this comment.
Just noting this is skipped and so the Trip instance doesn't have a reference to the driver for the trip.
| driver_id: 2 | ||
| } | ||
| @trip = RideShare::Trip.new(@trip_data) | ||
| @driver = RideShare::Driver.new( |
There was a problem hiding this comment.
You should connect this driver to @trip to use in the skipped test.
| total_rating = 0 | ||
| number_of_finished_trips = 0 | ||
| @trips.each do |trip| | ||
| if trip.end_time != nil | ||
| total_rating += trip.rating | ||
| number_of_finished_trips += 1 | ||
| end |
There was a problem hiding this comment.
Just noting you can simplify this a bit with enumerables
| total_rating = 0 | |
| number_of_finished_trips = 0 | |
| @trips.each do |trip| | |
| if trip.end_time != nil | |
| total_rating += trip.rating | |
| number_of_finished_trips += 1 | |
| end | |
| return 0 if trips.length == 0 | |
| completed_trips = trips.select { |trip| !trip.rating.nil? } | |
| total_ratings = completed_trips.reduce(0) do |sum, trip | | |
| sum + trip.rating | |
| end | |
| return total_ratings / completed_trips.length.to_f |
| end | ||
| end | ||
|
|
||
| def total_revenue |
There was a problem hiding this comment.
Well done, This works well.
I suggest you look up and see how you could adapt the code I wrote above, just for practice using enumerables.
| start_time: Time.parse(record[:start_time]).utc, # addedd Time.parse and utc to change the time from csv | ||
| end_time: Time.parse(record[:end_time]).utc, #style which is a string to give us time object |
Assignment Submission: OO Ride Share
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.
Reflection