Skip to content

Tanja Stroble -- Carets Ride Share#23

Open
misstonbon wants to merge 2 commits into
Ada-C8:masterfrom
misstonbon:patch-1
Open

Tanja Stroble -- Carets Ride Share#23
misstonbon wants to merge 2 commits into
Ada-C8:masterfrom
misstonbon:patch-1

Conversation

@misstonbon

Copy link
Copy Markdown

No description provided.

@CheezItMan CheezItMan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A few comments, a creative approach to organizing the data, but a little difficult to maintain.

Comment thread Tanja Stroble
i = 0
drivers = [ # drivers array
#index 0 of drivers array
driver1 = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You don't need things like this driver1 = { here.

I also think making these internal hashes containing 3 arrays, rather awkward to traverse. It's also problematic if you accidentally add an element to one array and not the others, they become out of synch.

I would suggest instead doing something like:

driver = [
  {RD0073: [
    {ride_id: "RD0003", rating: 3, pay: 10, dates_active: "2016-02-03"},
    {ride_id: "RD0004", rating: 4, pay: 12, dates_active: "2016-02-07"}
    ]
  }
]    

That makes it easier to loop through things and keeps trips together logically.

Comment thread Tanja Stroble
drivers.each do |driver|
i += 1
puts "Driver#{i} pay: $#{driver[:pay].sum} for #{driver[:ride_id].length} rides." #calculating pay and ride number
puts "Driver#{i}'s average rating is #{(driver[:rating].inject(0.0) { |sum, el| sum + el } / driver[:rating].size).round(2)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice work using an enumerable (inject) to sum up the pay.

Also good work using round.

@CheezItMan

Copy link
Copy Markdown
Collaborator

Feedback provided in code notes

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