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 Stephanie_Ride_Share.rb #27

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

Conversation

stephaniejmars
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? At first I had two loops, the first one for finding the number of rides the drivers have given, and the second for how much money the drivers had made. Once this was built I realized I could compute the rest of the questions using these two loops. Once I got the code to answer all the questions I saw I was using the same structure in each loop and was able to combine everything into the same loop.
What was your strategy for going through the data structure and gathering information? I used an each loop for the drivers, and another each loop for the individual driver information.
What was an example of something that was necessary to store in a variable? Why was it necessary, useful, or helpful? Storing the best ratings and associated driver id, along with most pay and associated driver id helped to compare each diver to the highest rated/paid. Storing outside the loop ensured it wouldn't reset each loop and I could puts outside of the loop, so that it wouldn't print every 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 did not use .map, I used .each. I considered .map but I didn't want to create unnecessary arrays. I could have used map to create arrays with things like ratings and then used .max to find the best ratings.
Were some calculations easier than others? Why? Not particularly, the most difficult thing for me was figuring out which of the nested loops I needed to pull information from.

@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 ⚠ not really creating 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?
Perfect Indentation ✅, good indentation, but the block of code from 88-96, is pretty dense (not much spacing to break things into discrete steps).
Elegant/Clever
Descriptive/Readable
Concise
Logical/Organized ⚠ This could use being broken up into methods.

Summary

Nice work, you hit all the learning goals here. Well done.

Comment on lines +88 to +106
drivers.each { |driver, drive|
drive.each { |drives|
driver_pay += drives[:cost]
driver_rating += drives[:rating]
}
if driver_pay > max_pay
max_pay = driver_pay
max_driver = driver
end
driver_rating = (driver_rating / drive.length).round(2)
if driver_rating > best_rating
best_driver = driver
best_rating = driver_rating
end
puts "Driver #{driver} gave #{drive.length} rides and made a total of $#{driver_pay}.00.
Their average rating is #{driver_rating}"
driver_pay = 0
driver_rating = 0.0
}

Choose a reason for hiding this comment

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

This works and it's pretty readable, but I suggest looking at breaking each step into a method for practice breaking code into components.

It's also pretty dense.

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