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

Space - Jessica #41

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

Space - Jessica #41

wants to merge 1 commit into from

Conversation

seaweeddol
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 was an array of hashes at first, with no additional layers - i.e. the ID, cost, date, etc for each ride were all within one hash on the same layer. It evolved to have the driver ID as a key and all of their ride information as another nested array of hashes, because I realized it made more sense to associate all of the ride info under each individual driver.
What was your strategy for going through the data structure and gathering information? I used nested each loops to go through the data. I had a top level each loop to get into each set of driver info, and then another each loop with two parameters that corresponded to the key (driver ID) and value (array of hashes with individual rides).
What was an example of something that was necessary to store in a variable? Why was it necessary, useful, or helpful? For the last two questions, it was necessary to have several variables to compare values and hold the current driver and amount that were the highest. By having a variable, I was able to compare the current number to the previous one, and then replace it if the current number was higher.
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 each loops and the reduce method. I think I could have used .map in place of .reduce by putting the ride cost or rating into a map array, and then summing that. However, I think that would end up being more lines of code than using .reduce.
Were some calculations easier than others? Why? Yes. The totals were easier to do than the averages, since it was just adding everything together. For the averages, I initially did not have to_f included, so it was giving me an answer that I knew was incorrect since it was a whole number. After adding to_f, I was getting a long decimal number, so I had to add .round(2) to cut it off after two decimals.

@dHelmgren
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 ✔️
Yellow (Approaches Standards) 2-3 in Code Review && 2+ in Functional Requirements
Red (Not at Standard) 0,1 in Code Review or 0,1 in Functional Reqs, or assignment is breaking/doesn’t run with less than 5 minutes of debugging

Code Style Bonus Awards

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

Quality Yes?
Perfect Indentation

Comment on lines +81 to +93
ride_info.each do |driver|
driver.each do |id, rides|
puts "Driver #{id} has given #{rides.length} rides"
end
end

# - the total amount of money each driver has made
ride_info.each do |driver|
driver.each do |id, rides|
total_made = rides.reduce(0) {|sum, ride| sum + ride[:cost]}
puts "Driver #{id} has made $#{total_made}"
end
end

Choose a reason for hiding this comment

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

You're looping over ride_info a few times, is there any way that you could loop over it less by utilizing methods?

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