Skip to content

ride_share.rb#30

Open
sheland wants to merge 1 commit into
Ada-C10:masterfrom
sheland:master
Open

ride_share.rb#30
sheland wants to merge 1 commit into
Ada-C10:masterfrom
sheland:master

Conversation

@sheland

@sheland sheland commented Aug 13, 2018

Copy link
Copy Markdown

ride share

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
What did your data structure look like at first? Did this structure evolve over time? Why? My dataset was first organized as array -> hash->hash but now its hash -> array -> hash -> array. The whole dataset is now stored as a hash with 4 keys that represent the driver's ID number, the values of the ID keys are stored in a array of hashes. There's was a lot of manipulation of how to store the data, I also had to be mindful of closing bracket/curly brackets.
What was your strategy for going through the data structure and gathering information? I continued to restructure the data while trying to answer the questions. I was able to retrieve values that I needed by re-nesting my data. The less arrays/hashes I had, the easier it got to retrieve variables .
What was an example of something that was necessary to store in a variable? What was the scope of each of that variables? Why? I stored my ride_cost variable which represented the money earned by the drivers. I stored it because I needed it to calculate the total money earned from all drivers. I used that variable to find out how much each driver earned, the total amount earned and the maximum earned. The scope of this variable was defined after the 2nd iteration. There were a few times where I had issues with my variable repeating itself because I placed them *total_cost = 0 and sum_ratings = 0 before the first iteration with the rest of my variables. After experimenting with the placement, I placed them after the first iteration so that way the max value wouldn't be repeated for each driver.
Were some calculations easier than others? Why? Finding the total cost and the average rating was fine but finding which driver had the highest average rating and highest earning was more challenging because you had to match the max values with the drivers.

@CheezItMan

Copy link
Copy Markdown

Nice work, I like how you organized the data. The only suggestion I would give is to break the main program into methods and perhaps use some Enumerable methods. Overall, well done!

Comment thread ride_share.rb
@@ -0,0 +1,150 @@
begin

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be:

=begin

Comment thread ride_share.rb
sum_ratings = 0


puts "Driver: #{driver} gave #{rides.count} rides." #driver & rides "extracted" in line 123

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to have this code broken out into methods.

Comment thread ride_share.rb
sum_ratings = sum_ratings + rating
end

average = sum_ratings / rides.count

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you be doing integer or floating point division?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants