-
Notifications
You must be signed in to change notification settings - Fork 48
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
Create ride-share #40
base: master
Are you sure you want to change the base?
Conversation
Ride ShareMajor Learning Goals/Code Review
Functional Requirements
Overall Feedback
Code Style Bonus AwardsWas the code particularly impressive in code style for any of these reasons (or more...?)
SummaryOverall nice work. Your output is not very user-friendly but it works. Take a look at my comments and let me know what questions you have. |
@@ -0,0 +1,147 @@ | |||
######################################################## |
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.
Note. This file should be named ride-share.rb
Note the .rb
at the end.
number_of_rides = [] | ||
arr.each do |drivertrip| | ||
number_of_rides = drivertrip.map { |k, v| [k, v.count] }.to_h | ||
|
||
|
||
end | ||
return number_of_rides |
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.
Your indentation is a little off here, and in your other methods.
driver_data = [ { "DR0001"=> { "ride1"=> {"date"=> "3rd Feb 2016", | ||
"cost"=> 10, | ||
"riderid"=> "RD0003", | ||
"rating"=> 3}, | ||
"ride2"=> {"date"=> "3th Feb 2016", | ||
"cost"=> 30, | ||
"riderid"=> "RD0015", | ||
"rating"=> 4}, | ||
"ride3"=> {"date"=> "5th Feb 2016", | ||
"cost"=> 45, | ||
"riderid"=> "RD0003", | ||
"rating"=> 2}}, | ||
"DR0002"=> { "ride1"=> {"date"=> "3rd Feb 2016", | ||
"cost"=> 25, | ||
"riderid"=> "RD0073", | ||
"rating"=> 5}, | ||
"ride2"=>{"date"=> "4th Feb 2016", | ||
"cost"=> 15, | ||
"riderid"=> "RD0013", | ||
"rating"=> 1}, | ||
"ride3"=> {"date"=> "5th Feb 2016", | ||
"cost"=>35, | ||
"riderid"=> "RD0066", | ||
"rating"=> 3}}, | ||
"DR0003"=> { "ride1"=>{"date"=> "4th Feb 2016", | ||
"cost"=> 5, | ||
"riderid"=> "RD0066", | ||
"rating"=> 5}, | ||
"ride2"=> {"date"=> "5th Feb 2016", | ||
"cost"=>50, | ||
"riderid"=> "RD0003", | ||
"rating"=> 2}}, | ||
"DR0004"=> { "ride1"=> {"date"=> "3rd Feb 2016", | ||
"cost"=> 5, | ||
"riderid"=> "RD0022", | ||
"rating"=> 5}, | ||
"ride2"=>{"date"=> "4th Feb 2016", | ||
"cost"=> 10, | ||
"riderid"=> "RD0022", | ||
"rating"=> 4}, | ||
"ride3"=> {"date"=> "5th Feb 2016", | ||
"cost"=>20, | ||
"riderid"=> "RD0073", | ||
"rating"=> 5}}}] |
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 whole structure is just hard to read. Consider doing something like this:
driver_data = [
{
DR001: [
{
date: "4th Feb 2016",
cost: 5,
riderid: "RD0066"
rating: 2,
},
...
]
end | ||
|
||
number_of_rides = number_of_rides(driver_data) | ||
puts number_of_rides |
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 really tell the user that this data has to do with the number of rides for each driver.
Consider looping through number_of_rides
and printing each driver neatly on a separate line.
Assignment Submission: Ride Share
Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.
Reflection
.map
? If so, when? If not, why, or when would be a good opportunity to use it?