Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

halahaddad1
Copy link

Assignment Submission: Ride Share

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.

Reflection

Question Answer
What did your data structure look like at first? Did this structure evolve over time? Why? My data structure started off as an array with nested hashes, I decided it might be a good idea to start with a date layer, that proved quickly to not word very well
What was your strategy for going through the data structure and gathering information? my strategy was to mainly use each loops, and then apply maps or other enumerables when appropriate, I started off with many loops then started to abbreviate with a few methods to be called when necessary
What was an example of something that was necessary to store in a variable? Why was it necessary, useful, or helpful? an example would be using a variable initiated to zero, then using that variable to get drivers ids, by adding one with each pass of the loop
What kinds of iteration did you use? Did you use .map? If so, when? If not, why, or when would be a good opportunity to use it? I used .map when I needed an array returned with values
Were some calculations easier than others? Why? yes! once I established my two main hashes (array and average rating) it was way easier to used .max_by to get the highest earning and highest rating

@CheezItMan
Copy link

Ride Share

Major Learning Goals/Code Review

Criteria yes/no, and optionally any details/lines of code to reference
Correctly creates, reads, and modifies variables ✔️
Correctly creates and accesses arrays ✔️
Correctly creates and accesses hashes ✔️
Reasonably organizes large amounts of related data into nested arrays and hashes ✔️
Correctly iterates through a nested data structure using loops and/or Enumerable methods ✔️
Reasonably organizes small pieces of code into methods, and calls/invokes those methods ✔️

Functional Requirements

Functional Requirement yes/no
To the terminal, the program outputs the correct number of rides each driver has given ✔️
... outputs the total amount of money each driver has made ✔️
... outputs the average rating for each driver ✔️
... outputs which driver made the most money ✔️
... outputs which driver has the highest average rating ✔️

Overall Feedback

Overall Feedback Criteria yes/no
Green (Meets/Exceeds Standards) 4+ in Code Review && 3+ in Functional Requirements ✔️

Code Style Bonus Awards

Was the code particularly impressive in code style for any of these reasons (or more...?)

Quality Yes?
Descriptive/Readable
Concise

Summary

Overall 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 @@
########################################################

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.

Comment on lines +85 to +91
number_of_rides = []
arr.each do |drivertrip|
number_of_rides = drivertrip.map { |k, v| [k, v.count] }.to_h


end
return number_of_rides

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.

Comment on lines +36 to +79
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}}}]

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

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.

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